xorquew...@googlemail.com schrieb:
Hello.
I have some C code that's compiled with -fexceptions using
the lang/gnat-gcc43 port. I'm on 6.4-RELEASE-p2.
A function c_function in the C code takes a callback as an argument.
I'm passing this function the address of a function ext_function defined
in another language (Ada, to be precise, but it seems to happen
with C++ too). The main body of my program is written in this language
so C is effectively the "foreign" code (whatever).
If ext_function raises an exception, the exception is NOT propagated
through the C code, the process simply exits.
To clarify:
1. Ada_program_main calls c_function, passing ext_function as argument.
2. c_function calls ext_function.
3. ext_function raises exception.
4. process exits
In this case, the C code lives inside a dynamic library, which is
linked against /usr/local/lib/gcc-4.3.2/libgcc_s.so (I never specified
this explicity, I'm assuming -fexceptions causes this).
If I statically link the C code (so libgcc_s.so isn't involved, I think),
the exception is propagated correctly.
1. Ada_program_main calls c_function, passing ext_function as argument.
2. c_function calls ext_function.
3. ext_function raises exception.
4. stack unwinds back to Ada_program_main.
5. Ada_program_main handles exception.
Why is it that the code can't unwind the call stack correctly? Is this
a bug? The same code seems to work correctly on Debian Lenny with the same
compiler.
Any help would be appreciated.
xw
Are more C functions involved? E.g. is the function pointer passed to
qsort(), which lives in libc, which is not compiled with -fexceptions.
Look at the stack trace when the exception occurs. In gdb you can use
the command "catch throw" (sic) to break when an exception gets thrown.
Conversely you can break at the catcher with "catch catch" (if it gets
this far).
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"