Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 17 Jan 2009 23:14:04 +0000
From:      xorquewasp@googlemail.com
To:        freebsd-hackers@freebsd.org
Subject:   gcc 4.3.2 libgcc_s.so exception handling broken?
Message-ID:  <20090117231404.GB77134@logik.internal.network>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090117231404.GB77134>