binaryen icon indicating copy to clipboard operation
binaryen copied to clipboard

spec/f32.wast test 1603 fails with GCC 13

Open rathann opened this issue 2 years ago • 5 comments

When running binaryen 111 test suite after building it with GCC 13 on x86_64 running Fedora rawhide, I get the following failure:

1603/2511 CHECKING: ( assert_return ( invoke min ( f32.const 0x0p+0 ) ( f32.const -0x0p+0 ) ) ( f32.const -0x0p+0 ) ) [line: 1621]
seen 0, expected -0
Fatal: unexpected, should be identical

I have no idea why this is happening, especially since the previous test:

1602/2511 CHECKING: ( assert_return ( invoke min ( f32.const -0x0p+0 ) ( f32.const 0x0p+0 ) ) ( f32.const -0x0p+0 ) ) [line: 1620]
seen -0, expected -0

succeeds and differs only in argument order. Compiler bug perhaps?

NOTE: Successful compilation with GCC 13 requires a small patch adding explicit includes for <cstdint> to src/wat-lexer.h, which I'll open a PR for soon.

rathann avatar Jan 26 '23 14:01 rathann

Might be worth trying santizers on that test (in both gcc and clang), perhaps there is undefined behavior that gcc uses. Or, building a debug build would also be useful to check to see if optimizations are involved.

kripken avatar Jan 26 '23 17:01 kripken

@kripken I'd be happy to try sanitizers on that test. Could you give me some pointers on how to invoke them? The issue remains present in 112 release.

rathann avatar May 17 '23 19:05 rathann

Sure, here is how CI builds with address sanitizer:

https://github.com/WebAssembly/binaryen/blob/7c3a4690028beaa187e5b1810200359b6336b088/.github/workflows/ci.yml#L134-L154

Basically add -fsanitize=address to compile and link commands, using some CMake flags there. Can also try address,undefined for undefined behavior as well.

kripken avatar May 17 '23 19:05 kripken

hitting the same issue with binaryen 112 or newer on Alpine edge, looks like a similar issue also happens with the corresponding max() call

2001/2510 CHECKING: ( assert_return ( invoke max ( f32.const -0x0p+0 ) ( f32.const 0x0p+0 ) ) ( f32.const 0x0p+0 ) ) [line: 2019]
seen -0, expected 0
Fatal: unexpected, should be identical

maybe it's an issue with std::signbit? i tried reproducing the issue in compiler explorer, but couldn't get it to fail in the same way

ptrcnull avatar Aug 13 '23 02:08 ptrcnull

and, well, the same happens with the corresponding f64 functions

ptrcnull avatar Aug 13 '23 02:08 ptrcnull

FWIW this is no longer reproducible with binaryen 118 on current Fedora rawhide (GCC 14.1.1).

rathann avatar Jul 25 '24 16:07 rathann

Thanks for confirming @rathann , let's close this then.

kripken avatar Jul 25 '24 17:07 kripken

Fedora 39 (gcc 13.3.1) and 40 (gcc 14.1.1) builds passed as well.

rathann avatar Jul 25 '24 17:07 rathann

Binaryen 118 on Alpine with GCC 13.2.1 works as well

ptrcnull avatar Jul 25 '24 17:07 ptrcnull

Great!

kripken avatar Jul 25 '24 17:07 kripken