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. PiperOrigin-RevId: 367423349 Change-Id: I769b3444ce4fa60f941ccd2115b0b09ccc809f13
This commit is contained in:
parent
17f561f221
commit
16880d4e3c
|
@ -157,6 +157,7 @@ cc_library(
|
||||||
"//sandboxed_api/sandbox2:comms",
|
"//sandboxed_api/sandbox2:comms",
|
||||||
"//sandboxed_api/util:status",
|
"//sandboxed_api/util:status",
|
||||||
"@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/memory",
|
"@com_google_absl//absl/memory",
|
||||||
"@com_google_absl//absl/status",
|
"@com_google_absl//absl/status",
|
||||||
"@com_google_absl//absl/status:statusor",
|
"@com_google_absl//absl/status:statusor",
|
||||||
|
|
|
@ -150,6 +150,7 @@ add_library(sapi_vars ${SAPI_LIB_TYPE}
|
||||||
add_library(sapi::vars ALIAS sapi_vars)
|
add_library(sapi::vars ALIAS sapi_vars)
|
||||||
target_link_libraries(sapi_vars
|
target_link_libraries(sapi_vars
|
||||||
PRIVATE absl::core_headers
|
PRIVATE absl::core_headers
|
||||||
|
absl::dynamic_annotations
|
||||||
absl::status
|
absl::status
|
||||||
absl::statusor
|
absl::statusor
|
||||||
absl::str_format
|
absl::str_format
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
#include <glog/logging.h>
|
#include <glog/logging.h>
|
||||||
|
#include "absl/base/dynamic_annotations.h"
|
||||||
#include "absl/strings/str_cat.h"
|
#include "absl/strings/str_cat.h"
|
||||||
#include "absl/strings/str_format.h"
|
#include "absl/strings/str_format.h"
|
||||||
#include "sandboxed_api/var_abstract.h"
|
#include "sandboxed_api/var_abstract.h"
|
||||||
|
@ -57,10 +58,10 @@ 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;
|
||||||
|
// Make MSAN happy with long double.
|
||||||
|
ABSL_ANNOTATE_MEMORY_IS_INITIALIZED(val_, sizeof(val_));
|
||||||
SetLocal(&val_);
|
SetLocal(&val_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user