[LLVMdev] RFA: Problem with Exceptions

Bill Wendling isanbard at gmail.com
Fri Aug 31 10:43:18 PDT 2007


Hi Duncan,

> > I'm compiling this trivial program on Darwin:
> >
> > int main(int argc, char **argv) {
> >   try {
> >     throw argc;
> >   } catch(int i) {
> >     return i;
> >   }
> >
> >   return 0;
> > }
> >
> > However, it segfaults when I run it. I've attached the .s files
> > generated by LLVM and GCC, but it looks as if LLVM isn't generating a
> > gxx_personality_v0 section (like it does for Unwind_Resume, et al). Is
> > this what's causing the failure? Does anyone know how to get it to
> > generate this section?
>
> does it segfault if you link using mainline g++?  Where does the segfault
> occur - in the unwinder, or in the program itself (and if so, where)?
>
It segfaults if I compile the .s file with g++. The segfault's
occurring in the _Unwind_RaiseException function. It loops through
calling the personality function for each frame. The first time
through is fine, but the second time through it gets a bad address for
the personality function and barfs. Evan noticed that there was a bad
value in the Leh_frame_common_begin1 section:

.byte   0x1b    # Personality (pcrel sdata4)

where gcc has:

.byte   0x9b    # Personality (pcrel sdata4 indirect)

Changing this changed the segfault to:

terminate called after throwing an instance of 'int'
Abort trap

So we're getting closer at least. :-) Now I just need to figure out
why it's calling terminate and not catching the throw...

-bw



More information about the llvm-dev mailing list