mewmew / uc

A compiler for the µC language.
57 stars 5 forks source link

irgen: Segmentation fault when running sim05.c #76

Open mewmew opened 8 years ago

mewmew commented 8 years ago
u@x1 ~/D/g/s/g/m/uc> ./compile.sh testdata/noisy/simple/sim05.c
Compiling "testdata/noisy/simple/sim05.c"
SUCCESS: testdata/noisy/simple/sim05.c
u@x1 ~/D/g/s/g/m/uc> lli out.ll
42
42
42
42
42
42
42
42
42
3141592
110001000
#0 0x00007ffa26f3c7d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/bin/../lib/libLLVM-3.8.so+0x5ef7d8)
#1 0x00007ffa26f3a3c6 llvm::sys::RunSignalHandlers() (/usr/bin/../lib/libLLVM-3.8.so+0x5ed3c6)
#2 0x00007ffa26f3a5aa (/usr/bin/../lib/libLLVM-3.8.so+0x5ed5aa)
#3 0x00007ffa2625a0f0 __restore_rt (/usr/bin/../lib/libc.so.6+0x330f0)
#4 0x00007ffa27bacf12 llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, char const* const*) (/usr/bin/../lib/libLLVM-3.8.so+0x125ff12)
#5 0x0000000000414046 main (/usr/bin/lli+0x414046)
#6 0x00007ffa262472d1 __libc_start_main (/usr/bin/../lib/libc.so.6+0x202d1)
#7 0x00000000004170b9 _start (/usr/bin/lli+0x4170b9)
Stack dump:
0.  Program arguments: lli out.ll 
fish: “lli out.ll” terminated by signal SIGSEGV (Address boundary error)
mewmew commented 8 years ago

Seems to be related to an out of bounds error in the original C source of the sim05.c test case.

Warning from Clang, when compiling sim05.c:

testdata/noisy/simple/sim05.c:12:3: warning: array index 1 is past the end of the array (which contains 1 element) [-Warray-bounds]
  cr[1]=0;
  ^  ~
testdata/noisy/simple/sim05.c:8:3: note: array 'cr' declared here
  char cr[1];
  ^