summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorWouter van Oortmerssen <aardappel@gmail.com>2020-08-10 13:05:19 -0700
committerGitHub <noreply@github.com>2020-08-10 13:05:19 -0700
commit204ef4ed0b618138a22c55ddeba0477e374e9883 (patch)
treece677e10f6d5fec59f0ef1840669a36f46387039 /src/tools
parent66023842fda8e0a5cdd89fbae8555103b9685814 (diff)
downloadwabt-204ef4ed0b618138a22c55ddeba0477e374e9883.tar.gz
wabt-204ef4ed0b618138a22c55ddeba0477e374e9883.tar.bz2
wabt-204ef4ed0b618138a22c55ddeba0477e374e9883.zip
Made the interpreter "type-safe" in debug mode (#1512)
Adds a type field to `Value` to verify the right union member is being read. A Wasm module that has been validated shouldn't need this, but any code reading the wrong value would trigger UB, but still often work (like a uint32_t read from a uint64_t on little endian machine), and mask bugs. Turning this on found bugs in the PR I just landed (as I suspected) but also in older code.
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/spectest-interp.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/tools/spectest-interp.cc b/src/tools/spectest-interp.cc
index 693f2eaa..a212053c 100644
--- a/src/tools/spectest-interp.cc
+++ b/src/tools/spectest-interp.cc
@@ -703,7 +703,7 @@ wabt::Result JSONParser::ParseLaneConstValue(Type lane_type,
ExpectedValue* out_value,
string_view value_str,
AllowExpected allow_expected) {
- v128& v = out_value->value.value.v128_;
+ v128 v = out_value->value.value.Get<v128>();
switch (lane_type) {
case Type::I8: {
@@ -758,6 +758,8 @@ wabt::Result JSONParser::ParseLaneConstValue(Type lane_type,
PrintError("unknown concrete type: \"%s\"", lane_type.GetName());
return wabt::Result::Error;
}
+
+ out_value->value.value.Set<v128>(v);
return wabt::Result::Ok;
}