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

A similar crash bug maybe due to llvm::APInt::udiv and llvm::APInt::sdiv #140

Closed
zyz9740 opened this issue Jan 4, 2023 · 0 comments · Fixed by leaningtech/cheerp-compiler#212
Labels
crash the compiler crashes

Comments

@zyz9740
Copy link

zyz9740 commented Jan 4, 2023

Source

#include "cd.h"

int main() {
  int a;
  int32_t b = 8;
  for (;; a++) {
    double c = b / a;
    transparent_crc_bytes(&c, c, "", 1);
  }
  return 0;
}

Reproduce:
/opt/cheerp/bin/clang -target cheerp-wasm random.c -o random_cheerp.js > compile.cheerp.txt 2>&1

Log:

random.c:8:27: warning: incompatible pointer types passing 'double *' to parameter of type 'char *' [-Wincompatible-pointer-types]
    transparent_crc_bytes(&c, c, "", 1);
                          ^~
./cd.h:85:30: note: passing argument to parameter 'ptr' here
transparent_crc_bytes (char *ptr, int nbytes, char* vname, int flag)
                             ^
1 warning generated.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /opt/cheerp/bin/opt -march=cheerp -cheerp-linear-output=wasm -cheerp-lto -passes=function(CheerpLowerInvoke),function(simplifycfg),CallConstructors,GlobalDepsAnalyzer,TypeOptimizer,function(CheerpLowerSwitch),I64Lowering,function(ReplaceNopCastsAndByteSwaps),FreeAndDeleteRemoval,default<Os>,PartialExecuter,function(simplifycfg) -o /tmp/random-ab2bd1.bc /tmp/random-0d9257.bc
 #0 0x0000000001f9fe13 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/cheerp/bin/opt+0x1f9fe13)
 #1 0x0000000001f9e0e0 llvm::sys::RunSignalHandlers() (/opt/cheerp/bin/opt+0x1f9e0e0)
 #2 0x0000000001fa02bf (/opt/cheerp/bin/opt+0x1fa02bf)
 #3 0x00007f6339fb13c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x143c0)
 #4 0x0000000001ef9299 llvm::APInt::udiv(llvm::APInt const&) const (/opt/cheerp/bin/opt+0x1ef9299)
 #5 0x0000000001efb577 llvm::APInt::sdiv(llvm::APInt const&) const (/opt/cheerp/bin/opt+0x1efb577)
 #6 0x0000000002856e07 llvm::Interpreter::visitBinaryOperator(llvm::BinaryOperator&) (/opt/cheerp/bin/opt+0x2856e07)
 #7 0x0000000002840a6e (/opt/cheerp/bin/opt+0x2840a6e)
 #8 0x0000000002846c2f (/opt/cheerp/bin/opt+0x2846c2f)
 #9 0x00000000028430bc (/opt/cheerp/bin/opt+0x28430bc)
#10 0x000000000284314a (/opt/cheerp/bin/opt+0x284314a)
#11 0x0000000002849824 (/opt/cheerp/bin/opt+0x2849824)
#12 0x000000000284930b (/opt/cheerp/bin/opt+0x284930b)
#13 0x0000000002843480 cheerp::PartialExecuter::runOnModule(llvm::Module&) (/opt/cheerp/bin/opt+0x2843480)
#14 0x000000000284383c cheerp::PartialExecuterPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/cheerp/bin/opt+0x284383c)
#15 0x000000000225f41d (/opt/cheerp/bin/opt+0x225f41d)
#16 0x000000000189a687 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/cheerp/bin/opt+0x189a687)
#17 0x0000000000d2272a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::StringRef>, llvm::ArrayRef<llvm::PassPlugin>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool) (/opt/cheerp/bin/opt+0xd2272a)
#18 0x0000000000d31ad7 main (/opt/cheerp/bin/opt+0xd31ad7)
#19 0x00007f6339a710b3 __libc_start_main /build/glibc-sMfBJT/glibc-2.31/csu/../csu/libc-start.c:342:3
#20 0x0000000000d1b32e _start (/opt/cheerp/bin/opt+0xd1b32e)
clang-16: error: unable to execute command: Floating point exception (core dumped)
clang-16: error: optimizer command failed due to signal (use -v to see invocation)
Cheerp 1670679767-1~focal clang version 16.0.0
Target: cheerp-leaningtech-webbrowser-wasm
Thread model: posix
InstalledDir: /opt/cheerp/bin
clang-16: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-16: note: diagnostic msg: /tmp/random-322cf6.c
clang-16: note: diagnostic msg: /tmp/random-322cf6.sh
clang-16: note: diagnostic msg: 

********************

Version:

Cheerp 1670679767-1~focal clang version 16.0.0
Target: cheerp-leaningtech-webbrowser-wasm
Thread model: posix
InstalledDir: /opt/cheerp/bin

Detail as attached.
1-4-crash-rem.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash the compiler crashes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants