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

fa.c:125:27: runtime error: left shift of 1 by 31 places cannot be represented in type 'int' #793

Open
228938596 opened this issue Dec 16, 2022 · 4 comments

Comments

@228938596
Copy link

Build 【OSS-fuzz】 environment
1、compile
python infra/helper.py build_fuzzers --sanitizer undefined augeas
2、Check the output file
python infra/helper.py reproduce augeas augeas_fa_fuzzer build/out/augeas/crash-170324fc4f2264fa9dc8fd77e37199008ad3fbaa

error message:
fa.c:125:27: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
#0 0x4c0f64 in bitset_set /src/augeas/src/fa.c:125:27
#1 0x4b2156 in minimize_hopcroft /src/augeas/src/fa.c:1648:25
#2 0x4b04d0 in fa_minimize /src/augeas/src/fa.c:1782:13
#3 0x4b0207 in LLVMFuzzerTestOneInput /src/augeas/augeas_fa_fuzzer.cc:72:3
#4 0x4414d1 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/c
#5 0x42c832 in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) /src/llvm-project/compil
#6 0x4328c7 in fuzzer::FuzzerDriver(int*, char***, int ()(unsigned char const, unsigned long)) /src/l6:9
#7 0x45af12 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:19:10
#8 0x7f24a4d9682f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
#9 0x406e48 in _start (/out/augeas_fa_fuzzer+0x406e48)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior fa.c:125:27 in

@igalic
Copy link

igalic commented Dec 16, 2022

augeas/src/fa.c

Line 125 in 4f3bbeb

bs[bit/UINT_BIT] |= 1 << (bit % UINT_BIT);

i reckon instead of 1 we should have used 1u in these functions

@228938596
Copy link
Author

augeas/src/fa.c

Line 125 in 4f3bbeb

bs[bit/UINT_BIT] |= 1 << (bit % UINT_BIT);

我认为1我们应该1u在这些功能中使用而不是

Following your suggestion, indeed this error can be resolved, thanks
125 bs[bit/UINT_BIT] |= 1u << (bit % UINT_BIT);

@igalic
Copy link

igalic commented Dec 17, 2022

what about

augeas/src/fa.c

Line 121 in 4f3bbeb

bs[bit/UINT_BIT] &= ~(1 << (bit % UINT_BIT));
? does it also need to be changed to:

 bs[bit/UINT_BIT] &= ~(1u << (bit % UINT_BIT)); 

or does that break something?

When you find out, can you please submit a pull request?

@228938596
Copy link
Author

228938596 commented Dec 21, 2022

关于什么

augeas/src/fa.c

Line 121 in 4f3bbeb

bs[bit/UINT_BIT] &= ~(1 << (bit % UINT_BIT));

?是不是也需要改成:

 bs[bit/UINT_BIT] &= ~(1u << (bit % UINT_BIT)); 

还是那会破坏某些东西?

当你发现时,你能提出一个拉取请求吗?

Yes, line 121 needs to be modified

@228938596 228938596 reopened this Dec 21, 2022
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