exception aborts the program on x86-32 when a program refers to an external function

Bug #894816 reported by Pekka Jääskeläinen on 2011-11-25
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Pekka Jääskeläinen

Bug Description

This is the expected error message from tcecc when the program has a function call to an undefined function:

../../../../src/base/program/ 'procedure with symbol: do_something not found!'

However, when running with 32bit x86 the exception that finally is caught in is not propagated but causes a program abort: terminate called after throwing an instance of 'InstanceNotFound'

This must have something to do with exception handling in LLVM. IIRC LLVM doesn't use exceptions and maybe it disables them completely and this TCE code linked with such a library then fails when trying to propagate an exception through the LLVM libs.

The backtrace:

Program received signal SIGABRT, Aborted.
0x0012d422 in __kernel_vsyscall ()
(gdb) bt
#0 0x0012d422 in __kernel_vsyscall ()
#1 0x02fb7651 in *__GI_raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#2 0x02fbaa82 in *__GI_abort () at abort.c:92
#3 0x02f1152f in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/
#4 0x02f0f465 in ?? () from /usr/lib/
#5 0x02f0f4a2 in std::terminate() () from /usr/lib/
#6 0x02f0f5e1 in __cxa_throw () from /usr/lib/
#7 0x025fdf0c in TTAProgram::Program::convertSymbolRef (this=0x80b38a8, tsr=...) at
#8 0x025fed59 in TTAProgram::Program::convertSymbolRefsToInsRefs (this=0x80b38a8) at
#9 0x02b4eaca in llvm::LLVMTCEIRBuilder::doFinalization (this=0x80a9ef0, m=...) at
#10 0x017a77ae in llvm::FPPassManager::doFinalization (this=0x8092b00, M=...) at PassManager.cpp:1552
#11 0x017afe45 in llvm::FPPassManager::runOnModule (this=0x8092b00, M=...) at PassManager.cpp:1536
#12 0x017af901 in llvm::MPPassManager::runOnModule (this=0x8089bd8, M=...) at PassManager.cpp:1588
#13 0x017afa3a in llvm::PassManagerImpl::run (this=0x8089a30, M=...) at PassManager.cpp:1672
#14 0x017afb30 in llvm::PassManager::run (this=0xbfffea08, M=...) at PassManager.cpp:1716
#15 0x02af4b62 in LLVMBackend::compile (this=0xbfffed1c, module=..., emulationModule=0x80a2ca8, plugin=..., target=..., optLevel=3, ipData=0x807eff8) at
#16 0x02af3b47 in LLVMBackend::compile (this=0xbfffed1c, bytecodeFile=..., emulationBytecodeFile=..., target=..., optLevel=3, debug=false, ipData=0x807eff8) at
#17 0x0804ad44 in main (argc=13, argv=0xbfffeec4) at

Related branches

Vladimir Guzma (vladimir-guzma) wrote :

If you can produce input file that triggers exception, I can try on Mac OSX if the OS makes any difference in output.
With 32 and 64bit builds of tools.

It might not be strictly a 32bit vs. 64bit issue, but just a matter of luck...

Every code like this reproduces it:

#include <stdint.h>

void do_something();

int main() {
   return 0;

However, by googling around (*) on this issue it becomes clear that throwing exceptions across shared library boundaries is risky and fragile. So in this case we should do what Kultala suggested in IRC: print an error to std::cerr where this is detected and exit(2). Not throw and assume the CLI code is able to catch it through several layers of different plugins/shared libs.


Changed in tce:
assignee: nobody → Pekka Jääskeläinen (pekka-jaaskelainen)

Now fails gracefully both on x86 and x86-64 with

"Error: procedure 'do_something' not found!"

Changed in tce:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers