[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problem with exception handling: WAS: no thread-safe +initialize in
From: |
Sebastian Reitenbach |
Subject: |
Re: Problem with exception handling: WAS: no thread-safe +initialize in old gnustep runtime? |
Date: |
Mon, 13 Jun 2011 13:34:43 +0200 |
User-agent: |
SOGoMail 1.3.7 |
On Monday, June 13, 2011 10:41 CEST, Richard Frith-Macdonald <rfm@gnu.org>
wrote:
>
> On 12 Jun 2011, at 12:56, Sebastian Reitenbach wrote:
>
> >
> > commenting out the line below in -[NSException raise], allows Sudoku to
> > work as expected, also Burn seems to behave fine.
> > I've seen other programs hanging in NSCountFrames() before, but that were
> > on error cases, so making sure not running into an error, fixed the
> > problem...
> > While I was testing for the release of the latest stable versions of
> > gnustep, I ran the test suite. The -base testsuite did hang in a couple of
> > places, where Richard already suspected a problem with the Exception
> > handling. I had to kill the processes, to make the testuite go on. With the
> > line commented out, the testuite also runs successfully to the end.
> >
> > 1609 Passed tests
> > 13 Dashed hopes
> > 1 Skipped set
> >
> > All OK!
> >
> >
> > - (void) raise
> > {
> > if (_reserved == 0)
> > {
> > _reserved = NSZoneCalloc([self zone], 2, sizeof(id));
> > }
> > //_e_stack = [GSStackTrace new];
> >
> > #if defined(_NATIVE_OBJC_EXCEPTIONS)
> > @throw self;
> > #else
> >
> > I don't think that just commenting out this line is the right/best solution
> > to the problem, but I hope its enough information for someone with more
> > insight to have a better idea how to fix it. Fixing it the right way would
> > be great step forward for GNUstep on OpenBSD (:
>
> OK ... what's happening here is we are generating a stack trace by using
> methods to work back up the stack ...
> On some architectures (and in any system where the stack is messed up (eg by
> the ffcall library) this procedure can get to a point where it causes a
> signal (such as segmentation fault) ... this is normal/expected. The fact
> that gdb stops at this point is NOT normally an indication of any
> error/problem.
Ah, OK. When I continue Sudoku in gdb, it also goes on after the SIGSEV,
afterwards, it starts to hang again. When I then when it "hangs", press Ctrl-C,
and then look at the backtrace, it hangs again, at more or less the same place
in NSCountFrames();
> The stack trace code therefore uses a signal handler to trap the signal and
> deal with it gracefully by stopping the construction of the stack trace at
> the point where it's hit a problem in the stack. It seems this may not be
> working properly for you.
>
> Now, this ties in with your problem with NSTask ... since the NSTask code
> also uses a signal handler to detect when a child process has terminated. So
> a failure to detect child termination may well be due to some problem with
> signal handling.
>
> So, my guess is that your BSD system is handling signals oddly ... the signal
> handler code in gnustep uses very old and well tested posix signal semantics
> but there are lots of newer or system dependent tweaks on signal handling.
> Maybe theres something we need to be doing special on your system to get
> signal handling to work as expected? Or maybe there's some subtle bug in the
> signal handling which just doesn't show uyp on other systems. Either way, it
> might be worth looking at that and seeing if writing/using some alternative
> BSD signal handling code would solve the issues.
I think I'm getting closer now, I added a lot of NSLogs(), and found that in
the jbuf_type struct bus and segv are always null, and I was wondering about
it. So started to compare manual pages of OpenBSD signal(3) and Linux
signal(2), and found, that they are indeed different:
http://www.openbsd.org/cgi-bin/man.cgi?query=signal&apropos=0&sektion=0&manpath=OpenBSD+Current&arch=i386&format=html
http://linux.die.net/man/2/signal
signal(3) on OpenBSD is a void function, but on Linux it returns sighandler_t,
so I changed it the code from:
env->segv = signal(SIGSEGV, recover);
env->bus = signal(SIGBUS, recover);
to:
signal(SIGSEGV, recover);
signal(SIGBUS, recover);
env->segv = recover;
env->bus = recover;
Now, I see that those values are set, but it still hangs, see below the output,
where I added a couple of NSLog statements in NSDebug and NSException:
2011-06-13 13:16:03.099 Sudoku[16840] NSException raise was called,_reserved
was 0
2011-06-13 13:16:03.100 Sudoku[16840] GSStacktrace init!, but I don't have
backtrace!
2011-06-13 13:16:03.100 Sudoku[16840] GSPrivateStackAddresses was called
2011-06-13 13:16:03.100 Sudoku[16840] jbuf: dict: {GSjbuf = <00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000>; NSConnectionThreadKey = "<NSConnection:
0x8a651258> local: '',<NSMessagePort 0x7f051328 file name
/tmp/GNUstepSecure1000/NSMessagePort/ports/16840.0> remote '',<NSMessagePort
0x7f051328 file name /tmp/GNUstepSecure1000/NSMessagePort/ports/16840.0>";
NSCurrentServerThreadKey = "<XGServer: 0x80040608>"; NSGraphicsContextStackKey
= (); NotificationQueueListThreadKey = "<NotificationQueueList: 0x85543568>";
NotificationQueueThreadKey = "<NSNotificationQueue: 0x80bf6ce8>";
sharedHorizontalTypesetter = "<GSHorizontalTypesetter: 0x7ccac088>"; }, d:
<00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000>
2011-06-13 13:16:03.101 Sudoku[16840] NSCountFrames before if: env->segv:
(null), env->bus: (null)
2011-06-13 13:16:03.106 Sudoku[16840] NSCountFrames in if: env->segv:
0x1fcd484, env->bus: 0x1fcd484
2011-06-13 13:16:03.106 Sudoku[16840] NSCountFrames in done: env->segv:
0x1fcd484, env->bus: 0x1fcd484
2011-06-13 13:16:03.106 Sudoku[16840] jbuf: dict: {GSjbuf = <9e04fd01 00210222
8c4dbdcf b84dbdcf 88d88b89 7402487f 00000000 01000000 00000000 00000000
00000000 64000000 84d4fc01 84d4fc01>; NSConnectionThreadKey = "<NSConnection:
0x8a651258> local: '',<NSMessagePort 0x7f051328 file name
/tmp/GNUstepSecure1000/NSMessagePort/ports/16840.0> remote '',<NSMessagePort
0x7f051328 file name /tmp/GNUstepSecure1000/NSMessagePort/ports/16840.0>";
NSCurrentServerThreadKey = "<XGServer: 0x80040608>"; NSGraphicsContextStackKey
= (); NotificationQueueListThreadKey = "<NotificationQueueList: 0x85543568>";
NotificationQueueThreadKey = "<NSNotificationQueue: 0x80bf6ce8>";
sharedHorizontalTypesetter = "<GSHorizontalTypesetter: 0x7ccac088>"; }, d:
<9e04fd01 00210222 8c4dbdcf b84dbdcf 88d88b89 7402487f 00000000 01000000
00000000 00000000 00000000 64000000 84d4fc01 84d4fc01>
2011-06-13 13:16:03.374 Sudoku[16840] NSException raise was called,_reserved
was 0
2011-06-13 13:16:03.375 Sudoku[16840] GSStacktrace init!, but I don't have
backtrace!
2011-06-13 13:16:03.375 Sudoku[16840] GSPrivateStackAddresses was called
2011-06-13 13:16:03.376 Sudoku[16840] jbuf: dict: {GSjbuf = <e497fd01 00210222
bc4dbdcf 984fbdcf e0b6f921 7402487f 00000000 01000000 00000000 00000000
00000000 c0ba001c 84d4fc01 84d4fc01>; NSConnectionThreadKey = "<NSConnection:
0x8a651258> local: '',<NSMessagePort 0x7f051328 file name
/tmp/GNUstepSecure1000/NSMessagePort/ports/16840.0> remote '',<NSMessagePort
0x7f051328 file name /tmp/GNUstepSecure1000/NSMessagePort/ports/16840.0>";
NSCurrentServerThreadKey = "<XGServer: 0x80040608>"; NSGraphicsContextStackKey
= (); NotificationQueueListThreadKey = "<NotificationQueueList: 0x85543568>";
NotificationQueueThreadKey = "<NSNotificationQueue: 0x80bf6ce8>";
sharedHorizontalTypesetter = "<GSHorizontalTypesetter: 0x7ccac088>"; }, d:
<e497fd01 00210222 bc4dbdcf 984fbdcf e0b6f921 7402487f 00000000 01000000
00000000 00000000 00000000 c0ba001c 84d4fc01 84d4fc01>
2011-06-13 13:16:03.377 Sudoku[16840] NSCountFrames before if: env->segv:
0x1fcd484, env->bus: 0x1fcd484
2011-06-13 13:16:03.381 Sudoku[16840] NSCountFrames in if: env->segv:
0x1fcd484, env->bus: 0x1fcd484
2011-06-13 13:16:03.382 Sudoku[16840] jbuf: dict: {GSjbuf = <9e04fd01 00210222
8c87bdcf b887bdcf 4858c085 c4435d85 00000000 01000000 00000000 00000000
00000000 48000000 84d4fc01 84d4fc01>; NSConnectionThreadKey = "<NSConnection:
0x8a651258> local: '',<NSMessagePort 0x7f051328 file name
/tmp/GNUstepSecure1000/NSMessagePort/ports/16840.0> remote '',<NSMessagePort
0x7f051328 file name /tmp/GNUstepSecure1000/NSMessagePort/ports/16840.0>";
NSCurrentServerThreadKey = "<XGServer: 0x80040608>"; NSGraphicsContextStackKey
= (); NotificationQueueListThreadKey = "<NotificationQueueList: 0x85543568>";
NotificationQueueThreadKey = "<NSNotificationQueue: 0x80bf6ce8>";
sharedHorizontalTypesetter = "<GSHorizontalTypesetter: 0x7ccac088>"; }, d:
<9e04fd01 00210222 8c87bdcf b887bdcf 4858c085 c4435d85 00000000 01000000
00000000 00000000 00000000 48000000 84d4fc01 84d4fc01>
2011-06-13 13:16:03.382 Sudoku[16840] recover: I got called, jumping to:
0x87a97980
2011-06-13 13:16:03.382 Sudoku[16840] jbuf: dict: {GSjbuf = <9e04fd01 00210222
8c87bdcf b887bdcf 4858c085 c4435d85 00000000 01000000 00000000 00000000
00000000 48000000 84d4fc01 84d4fc01>; NSConnectionThreadKey = "<NSConnection:
0x8a651258> local: '',<NSMessagePort 0x7f051328 file name
/tmp/GNUstepSecure1000/NSMessagePort/ports/16840.0> remote '',<NSMessagePort
0x7f051328 file name /tmp/GNUstepSecure1000/NSMessagePort/ports/16840.0>";
NSCurrentServerThreadKey = "<XGServer: 0x80040608>"; NSGraphicsContextStackKey
= (); NotificationQueueListThreadKey = "<NotificationQueueList: 0x85543568>";
NotificationQueueThreadKey = "<NSNotificationQueue: 0x80bf6ce8>";
sharedHorizontalTypesetter = "<GSHorizontalTypesetter: 0x7ccac088>"; }, d:
<9e04fd01 00210222 8c87bdcf b887bdcf 4858c085 c4435d85 00000000 01000000
00000000 00000000 00000000 48000000 84d4fc01 84d4fc01>
2011-06-13 13:16:03.390 Sudoku[16840] NSCountFrames in else: env->segv:
0x1fcd484, env->bus: 0x1fcd484
2011-06-13 13:16:03.390 Sudoku[16840] jbuf: dict: {GSjbuf = <9e04fd01 00210222
8c87bdcf b887bdcf 4858c085 c4435d85 00000000 01000000 00000000 00000000
00000000 48000000 84d4fc01 84d4fc01>; NSConnectionThreadKey = "<NSConnection:
0x8a651258> local: '',<NSMessagePort 0x7f051328 file name
/tmp/GNUstepSecure1000/NSMessagePort/ports/16840.0> remote '',<NSMessagePort
0x7f051328 file name /tmp/GNUstepSecure1000/NSMessagePort/ports/16840.0>";
NSCurrentServerThreadKey = "<XGServer: 0x80040608>"; NSGraphicsContextStackKey
= (); NotificationQueueListThreadKey = "<NotificationQueueList: 0x85543568>";
NotificationQueueThreadKey = "<NSNotificationQueue: 0x80bf6ce8>";
sharedHorizontalTypesetter = "<GSHorizontalTypesetter: 0x7ccac088>"; }, d:
<9e04fd01 00210222 8c87bdcf b887bdcf 4858c085 c4435d85 00000000 01000000
00000000 00000000 00000000 48000000 84d4fc01 84d4fc01>
2011-06-13 13:16:03.458 Sudoku[16840] 0 tries, picked
000000000000000000000000000000111111111111111111111111111111111111111111111112300
over (null)
2011-06-13 13:16:03.593 Sudoku[16840] NSException raise was called,_reserved
was 0
2011-06-13 13:16:03.593 Sudoku[16840] GSStacktrace init!, but I don't have
backtrace!
2011-06-13 13:16:03.594 Sudoku[16840] GSPrivateStackAddresses was called
2011-06-13 13:16:03.594 Sudoku[16840] jbuf: dict: {GSjbuf = <e497fd01 00210222
bc87bdcf 9889bdcf e0b6f921 c4435d85 00000000 01000000 00000000 00000000
00000000 e4ecbdcf 84d4fc01 84d4fc01>; NSConnectionThreadKey = "<NSConnection:
0x8a651258> local: '',<NSMessagePort 0x7f051328 file name
/tmp/GNUstepSecure1000/NSMessagePort/ports/16840.0> remote '',<NSMessagePort
0x7f051328 file name /tmp/GNUstepSecure1000/NSMessagePort/ports/16840.0>";
NSCurrentServerThreadKey = "<XGServer: 0x80040608>"; NSGraphicsContextStackKey
= (); NotificationQueueListThreadKey = "<NotificationQueueList: 0x85543568>";
NotificationQueueThreadKey = "<NSNotificationQueue: 0x80bf6ce8>";
sharedHorizontalTypesetter = "<GSHorizontalTypesetter: 0x7ccac088>"; }, d:
<e497fd01 00210222 bc87bdcf 9889bdcf e0b6f921 c4435d85 00000000 01000000
00000000 00000000 00000000 e4ecbdcf 84d4fc01 84d4fc01>
2011-06-13 13:16:03.598 Sudoku[16840] NSCountFrames before if: env->segv:
0x1fcd484, env->bus: 0x1fcd484
2011-06-13 13:16:03.600 Sudoku[16840] NSCountFrames in if: env->segv:
0x1fcd484, env->bus: 0x1fcd484
>
- no thread-safe +initialize in old gnustep runtime?, Sebastian Reitenbach, 2011/06/06
- Re: no thread-safe +initialize in old gnustep runtime?, Nicola Pero, 2011/06/08
- Re: Problem with exception handling: WAS: no thread-safe +initialize in old gnustep runtime?, Sebastian Reitenbach, 2011/06/13
- Re: Problem with exception handling: WAS: no thread-safe +initialize in old gnustep runtime?, David Chisnall, 2011/06/13
- Re: Problem with exception handling: WAS: no thread-safe +initialize in old gnustep runtime?, Sebastian Reitenbach, 2011/06/13
- Re: Problem with exception handling: WAS: no thread-safe +initialize in old gnustep runtime?, Sebastian Reitenbach, 2011/06/14
- Re: Problem with exception handling: WAS: no thread-safe +initialize in old gnustep runtime?, David Chisnall, 2011/06/14
- Re: Problem with exception handling: WAS: no thread-safe +initialize in old gnustep runtime?, Richard Frith-Macdonald, 2011/06/14
- Re: Problem with exception handling: WAS: no thread-safe +initialize in old gnustep runtime?, Richard Frith-Macdonald, 2011/06/14
- Re: Problem with exception handling: WAS: no thread-safe +initialize in old gnustep runtime?, Riccardo Mottola, 2011/06/14