mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Fix Reg<long double>
for MSAN
On x86 `long double` has 10 bytes of meaningful data, but `sizeof(long double)` is 16 - the remaining bytes are random garbage. Roll forward after fixing a bug in the original commit. PiperOrigin-RevId: 368170639 Change-Id: I4a1d2d95b92eed6b71c37145726f7320cfc00ba0
This commit is contained in:
parent
141fe911f5
commit
00649577d9
|
@ -86,6 +86,7 @@ cc_library(
|
||||||
"//sandboxed_api/util:status",
|
"//sandboxed_api/util:status",
|
||||||
"@com_google_absl//absl/base",
|
"@com_google_absl//absl/base",
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
|
"@com_google_absl//absl/base:dynamic_annotations",
|
||||||
"@com_google_absl//absl/container:flat_hash_map",
|
"@com_google_absl//absl/container:flat_hash_map",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
"@com_google_absl//absl/status",
|
"@com_google_absl//absl/status",
|
||||||
|
|
|
@ -75,7 +75,8 @@ add_library(sapi_sapi ${SAPI_LIB_TYPE}
|
||||||
)
|
)
|
||||||
add_library(sapi::sapi ALIAS sapi_sapi)
|
add_library(sapi::sapi ALIAS sapi_sapi)
|
||||||
target_link_libraries(sapi_sapi
|
target_link_libraries(sapi_sapi
|
||||||
PRIVATE absl::flat_hash_map
|
PRIVATE absl::dynamic_annotations
|
||||||
|
absl::flat_hash_map
|
||||||
absl::memory
|
absl::memory
|
||||||
absl::status
|
absl::status
|
||||||
absl::statusor
|
absl::statusor
|
||||||
|
|
|
@ -396,6 +396,8 @@ void ServeRequest(sandbox2::Comms* comms) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret.ret_type == v::Type::kFloat) {
|
if (ret.ret_type == v::Type::kFloat) {
|
||||||
|
// Make MSAN happy with long double.
|
||||||
|
ABSL_ANNOTATE_MEMORY_IS_INITIALIZED(&ret.float_val, sizeof(ret.float_val));
|
||||||
VLOG(1) << "Returned value: " << ret.float_val
|
VLOG(1) << "Returned value: " << ret.float_val
|
||||||
<< ", Success: " << (ret.success ? "Yes" : "No");
|
<< ", Success: " << (ret.success ? "Yes" : "No");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include <glog/logging.h>
|
#include <glog/logging.h>
|
||||||
#include "absl/base/casts.h"
|
#include "absl/base/casts.h"
|
||||||
|
#include "absl/base/dynamic_annotations.h"
|
||||||
#include "absl/base/macros.h"
|
#include "absl/base/macros.h"
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
|
@ -323,6 +324,9 @@ absl::Status Sandbox::Call(const std::string& func, v::Callable* ret,
|
||||||
if (arg->GetType() == v::Type::kFloat) {
|
if (arg->GetType() == v::Type::kFloat) {
|
||||||
arg->GetDataFromPtr(&rfcall.args[i].arg_float,
|
arg->GetDataFromPtr(&rfcall.args[i].arg_float,
|
||||||
sizeof(rfcall.args[0].arg_float));
|
sizeof(rfcall.args[0].arg_float));
|
||||||
|
// Make MSAN happy with long double.
|
||||||
|
ABSL_ANNOTATE_MEMORY_IS_INITIALIZED(&rfcall.args[i].arg_float,
|
||||||
|
sizeof(rfcall.args[0].arg_float));
|
||||||
} else {
|
} else {
|
||||||
arg->GetDataFromPtr(&rfcall.args[i].arg_int,
|
arg->GetDataFromPtr(&rfcall.args[i].arg_int,
|
||||||
sizeof(rfcall.args[0].arg_int));
|
sizeof(rfcall.args[0].arg_int));
|
||||||
|
|
|
@ -57,9 +57,7 @@ class Reg : public Callable {
|
||||||
"Only register-sized types are allowed as template argument "
|
"Only register-sized types are allowed as template argument "
|
||||||
"for class Reg.");
|
"for class Reg.");
|
||||||
|
|
||||||
Reg() : Reg(static_cast<T>(0)) {}
|
explicit Reg(const T val = {}) {
|
||||||
|
|
||||||
explicit Reg(const T val) {
|
|
||||||
val_ = val;
|
val_ = val;
|
||||||
SetLocal(&val_);
|
SetLocal(&val_);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user