diff options
author | Wouter van Oortmerssen <aardappel@gmail.com> | 2020-08-10 13:05:19 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-10 13:05:19 -0700 |
commit | 204ef4ed0b618138a22c55ddeba0477e374e9883 (patch) | |
tree | ce677e10f6d5fec59f0ef1840669a36f46387039 /src/shared-validator.cc | |
parent | 66023842fda8e0a5cdd89fbae8555103b9685814 (diff) | |
download | wabt-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/shared-validator.cc')
-rw-r--r-- | src/shared-validator.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/shared-validator.cc b/src/shared-validator.cc index 5f429e59..ef1b69e8 100644 --- a/src/shared-validator.cc +++ b/src/shared-validator.cc @@ -570,11 +570,11 @@ Result SharedValidator::CheckAlign(const Location& loc, Address alignment, Address natural_alignment) { if (!is_power_of_two(alignment)) { - PrintError(loc, "alignment (%u) must be a power of 2", alignment); + PrintError(loc, "alignment (%lu) must be a power of 2", alignment); return Result::Error; } if (alignment > natural_alignment) { - PrintError(loc, "alignment must not be larger than natural alignment (%u)", + PrintError(loc, "alignment must not be larger than natural alignment (%lu)", natural_alignment); return Result::Error; } @@ -585,11 +585,11 @@ Result SharedValidator::CheckAtomicAlign(const Location& loc, Address alignment, Address natural_alignment) { if (!is_power_of_two(alignment)) { - PrintError(loc, "alignment (%u) must be a power of 2", alignment); + PrintError(loc, "alignment (%lu) must be a power of 2", alignment); return Result::Error; } if (alignment != natural_alignment) { - PrintError(loc, "alignment must be equal to natural alignment (%u)", + PrintError(loc, "alignment must be equal to natural alignment (%lu)", natural_alignment); return Result::Error; } |