public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc 4.1 on FreeBSD 5.4 Objective-c @finally abort()'s.
@ 2005-07-09 11:37 Marcin Koziej
  0 siblings, 0 replies; only message in thread
From: Marcin Koziej @ 2005-07-09 11:37 UTC (permalink / raw)
  To: gcc-help


Hello!
I'm trying to use @finally clause with gcc 4.1 (compiled from port lang/gcc41) 
on FreeBSD 5.4, but it crashes with abort(). I don't have a linux box 
availible to test if this is freebsd's case, my error or gcc's. I tried to
debug it but run into gcc's exception handling internals (gcc/unwind.inc)
 which leave me without any ideas.

A simple program:

creep@carnivore[~p/paparazzi]:'< cat nt3.m
#import <objc/Object.h>

@interface Exception : Object
- print;
@end

@implementation Exception
- print
{
        printf("I'm an exception!\n");
        return self;
}
@end

void a();

int
main(int ac, char *av[])
{
        @try {
                a();
        }
        @catch (id pe)
        {
                printf("in main\n");
                [[pe print] free];
        }
        printf("end\n");

}

void a()
{
        printf("Beeble bah!\n");
        @try
        {
                @throw [Exception new];
        }
        @finally
        {
                printf("FINALLY\n");
        }
        printf("Not reached\n");
        return;

}

Running it:

creep@carnivore[~]:> gcc41 -v
Using built-in specs.
Target: i386-portbld-freebsd5.4
Configured with: ./..//gcc-4.1-20050702/configure --disable-rpath --disable-nls --with-system-zlib --with-libiconv-prefix=/usr/local --program-suffix=41 --libdir=/usr/local/lib/gcc/i386-portbld-freebsd5.4/4.1.0 --with-gxx-include-dir=/usr/local/lib/gcc/i386-portbld-freebsd5.4/4.1.0/include/c++/ --disable-shared --disable-libgcj --prefix=/usr/local i386-portbld-freebsd5.4
Thread model: posix
gcc version 4.1.0 20050702 (experimental)
creep@carnivore[~p/paparazzi]:> gcc41 -fobjc-exceptions nt3.m -I
/usr/local/lib/gcc/i386-portbld-freebsd5.4/4.1.0/include/ -lobjc
creep@carnivore[~p/paparazzi]:>
creep@carnivore[~p/paparazzi]:> ./a.out
Beeble bah!
FINALLY
zsh: abort (core dumped)  ./a.out
creep@carnivore[~p/paparazzi]:'< gdb -core a.out.core a.out
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and
you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for
details.
This GDB was configured as "i386-marcel-freebsd"...
Core was generated by `a.out'.
Program terminated with signal 6, Aborted.
Reading symbols from /lib/libc.so.5...done.
Loaded symbols for /lib/libc.so.5
Reading symbols from /usr/libexec/ld-elf.so.1...done.
Loaded symbols for /usr/libexec/ld-elf.so.1
#0  0x280d964f in kill () from /lib/libc.so.5
(gdb) bt
#0  0x280d964f in kill () from /lib/libc.so.5
#1  0x280cd286 in raise () from /lib/libc.so.5
#2  0x2814e972 in abort () from /lib/libc.so.5
#3  0x0805455b in _Unwind_Resume (exc=0x805d760) at unwind.inc:237
#4  0x0804903b in a ()
#5  0x08048f4a in main ()
(gdb)

I've done some debugging and it seems gcc/unwind.inc:_Unwind_Resume
does abort
237  gcc_assert (code == _URC_INSTALL_CONTEXT);

 due to code == _URC_FATAL_PHASE2_ERROR returned by
gcc/unwind.inc:_Unwind_RiseException_Phase2, which returns it because
of

54      /* Identify when we've reached the designated handler context.
*/
55      match_handler = (uw_identify_context (context) ==
exc->private_2
56               ? _UA_HANDLER_FRAME : 0);
57
58      if (code != _URC_NO_REASON)
59    /* Some error encountered.  Usually the unwinder doesn't
60       diagnose these and merely crashes.  */
61    return _URC_FATAL_PHASE2_ERROR;

here code being _URC_END_OF_STACK (instead of _URC_NO_REASON)

Here I get puzzled, because it seems unwinding misses the @catch in
main(). 

Any hints? Should I post a bug? (i tried to run gcc/testsuite/objc.dg/try-catch-1.m, after adding main() to it, with the same crash.)

m. 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-07-09 11:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-09 11:37 gcc 4.1 on FreeBSD 5.4 Objective-c @finally abort()'s Marcin Koziej

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).