Skip to content

Conversation

@tlively
Copy link
Member

@tlively tlively commented Dec 20, 2024

The UBSan builder started failing with an error about a misaligned store
in wasm-ctor-eval.cpp. The store was already done via memcpy to avoid
alignment issues, but apparently this is no longer enough. Use void*
as the destination type to further avoid giving the impression of
guaranteed alignment.

Also fix UB when executing std::abs on minimum negative integers in
literal.cpp.

The flake8 we were running on CI was too old and began giving spurious
errors about the uninterpreted contents of f-strings. Update to the
latest flake8 and fix all the new errors, including the previously
incorrect comment syntax in the .flake8 file.

Also remove scripts/storage.py, since it didn't seem to be used for
anything we currently need.
The UBSan builder started failing with an error about a misaligned store
in wasm-ctor-eval.cpp. The store was already done via `memcpy` to avoid
alignment issues, but apparently this is no longer enough. Add a cast to
`(void*)` to further avoid giving the impression of guaranteed
alignment.
Base automatically changed from fix-flake8 to main December 20, 2024 20:10
@tlively
Copy link
Member Author

tlively commented Dec 20, 2024

Wooo it works! @kripken PTAL at the latest state.

case Type::i64:
if (i64 == std::numeric_limits<int64_t>::min()) {
return *this;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, wasm doesn't have integer min, does it? Unless this is for SIMD somehow?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it's not a wasm instruction, it's some internal computation over literals... in that case we don't have a spec to compare against. Why is returning the (negative) literal the right value for abs here? (I would guess maxint)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, I found a testcase that uses this,

 (func $optimize-boolean (type $1) (param $0 i32) (param $1 i64) (result i32)
  (select
   (i32.const 0)
   (i32.const 0)
   (i32.rem_s
    (local.get $0)
    (i32.const 0)
   )
  )
 )

--optimize-instructions ends up doing abs on an integer here.

Reading the pass source, I'm not sure if this is a bug or not.

If you can confirm this PR doesn't change the outcome, that sounds ok, but I guess it's UB so we aren't sure it was consistent before?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an integer abs SIMD instruction, and we run a spec test for its behavior that shows this is WAI.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, sgtm then. Meanwhile I verified all uses of integer abs in OptimizeInstructions are valid.

Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea why this broke, btw? Compiler update on CI maybe?

@tlively
Copy link
Member Author

tlively commented Dec 21, 2024

Yeah they updated the latest ubuntu image recently, and I think it brought in subtly different versions of various things.

@tlively tlively merged commit 4d8a933 into main Dec 21, 2024
13 checks passed
@tlively tlively deleted the fix-ubsan branch December 21, 2024 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants