Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ubsan in unit/fp/fadd.opt: shift exponent 111 is too large #1160

Open
katrinafyi opened this issue Jan 13, 2025 · 3 comments
Open

ubsan in unit/fp/fadd.opt: shift exponent 111 is too large #1160

katrinafyi opened this issue Jan 13, 2025 · 3 comments

Comments

@katrinafyi
Copy link
Contributor

katrinafyi commented Jan 13, 2025

When running ubsan, there is an error reported in the fadd.opt unit test.

I only see this when using clang++ as the compiler and with the -fno-sanitize-recover=undefined flag added. Using g++ with the same CXXFLAGS does not seem to show the error.

export CXXFLAGS="-fsanitize=address,undefined -fno-sanitize-recover=undefined"
export CXX=$(which clang++)
rm -rf build; cmake -B build -GNinja -DCMAKE_PREFIX_PATH=~/progs/llvm-regehr/build/ -DBUILD_TV=1 -DCMAKE_VERBOSE_MAKEFILE=TRUE . && cmake --build build -j4
bash -c 'cd build; ../tests/lit/lit.py  ../tests/unit/fp/fadd.opt  -j10 --verbose'
-- Testing: 1 tests, 1 workers --
FAIL: Alive2 :: unit/fp/fadd.opt (1 of 1)
******************** TEST 'Alive2 :: unit/fp/fadd.opt' FAILED ********************
Processing /home/rina/progs/alive2/tests/unit/fp/fadd.opt..

----------------------------------------
Name: fsub, double, type infer
  %t = fsub double %a, 0.0
  ret double %t
=>
  %t = double %a
  ret %t

Done: 1
Transformation seems to be correct!

----------------------------------------
Name: fadd identical, double, constant
  %t = fadd double %a, 0.0
  ret double %t
=>
  %t = fadd double %a, 0.0
  ret double %t

Done: 1/home/rina/progs/alive2/ir/type.cpp:464:31: runtime error: shift exponent 111 is too large for 64-bit type 'unsigned long long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/rina/progs/alive2/ir/type.cpp:464:31 

This is 332cbac and clang version:

clang version 19.1.5
Target: x86_64-suse-linux

I noticed that https://github.com/regehr/alive2/blob/master/.github/workflows/build.yml is meant to run the tests with sanitizers, but I think that the environment variables should be named CXX and CXXFLAGS instead of their CMAKE_ versions. Also, -fno-sanitize-recover is needed, otherwise it only prints the violation and continues the program.

@regehr
Copy link
Contributor

regehr commented Jan 13, 2025

do you still get this with Alive2's top of tree, Kait? Nuno fixed a bug like this that someone else recently reported

@regehr
Copy link
Contributor

regehr commented Jan 13, 2025

or I guess he just merged an external fix!
9b2d131

@katrinafyi
Copy link
Contributor Author

I just checked and it does seem to happen on 332cbac, after that commit.

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

No branches or pull requests

2 participants