discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem with exception handling: WAS: no thread-safe +initialize in old


From: Sebastian Reitenbach
Subject: Problem with exception handling: WAS: no thread-safe +initialize in old gnustep runtime?
Date: Sun, 12 Jun 2011 13:56:12 +0200
User-agent: SOGoMail 1.3.7

 
On Thursday, June 9, 2011 17:27 CEST, "Sebastian Reitenbach" 
<sebastia@l00-bugdead-prods.de> wrote: 
 
>  
> On Wednesday, June 8, 2011 19:41 CEST, Nicola Pero 
> <nicola.pero@meta-innovation.com> wrote: 
>  
> > Sebastian,
> > 
> > it's difficult to say without having looked at the code.  I assume that 
> > nobody really answered
> > because they didn't have time to look at the actual code. :-(
> > 
> > Is your problem consistently reproducible ?  If so, it may not be a 
> > threading problem.  The non-thread-safe
> > implementation of +initialize can be a problem, but "in the wild" I'd 
> > expect the bug to occur, or not occur,
> > randomly, depending on the execution order of the threads (and it should 
> > only occur the first time a class
> > is used).
> > 
> > The snippet of code you show below uses NSTask, but I don't see any threads 
> > in it.  Is it a problem
> > with NSTask on OpenBSD not correctly detecting when the subprocess 
> > terminates, or what the
> > return value is ?
> > 
> > Anyhow, if there are some threads involved somewhere, and you suspect that 
> > the problem is the non-thread-safe
> > implementation of +initialize, then you should identify the classes with a 
> > suspicious +initialize method,
> > let's say NSObject and NSTask, and add calls such as
> >   
> >   [NSObject class]; 
> >   [NSTask class];
> > 
> > before you go multi-threaded (eg, in main()).  These calls do nothing, but 
> > trigger the +initialize.  If you trigger
> > it before starting any additional threads, you work around the 
> > "multi-threading" problem with +initialize.  Does
> > the problem disappear if you do this (with the correct classes there) ?  If 
> > so, it may well be the unsafe +initialize
> > bug.
> > 
> > I hope this helps. :-)
> Thanks, I was only guessing so far, whether the problem really is regarding 
> the threading, I'll see, it was the only obvious thing I observed so far, 
> which might be related, or not ;)
> 

As it seems, the +initialize was not the problem. I also tested Sudoku, and I 
found that, when I try to initialize a new Game, then Sudoku did hang. Running 
Sudoku in gdb, I found it segfaults in NSCountFrames()



The backtrace for Sudoku always looked like this:
(gdb) r
Starting program: /usr/local/bin/Sudoku 
2011-06-12 13:37:23.177 Sudoku[2758] Cannot load the main model file 
'Sudoku.gorm'
2011-06-12 13:37:23.257 Sudoku[2758] XShm not supported, XShmAttach() failed.
2011-06-12 13:37:23.258 Sudoku[2758] Falling back to normal XImage (will be 
slower).

Program received signal SIGSEGV, Segmentation fault.
[Switching to process 2758, thread 0x875bac00]
0x05004dc2 in NSCountFrames () at NSDebug.m:1005
1005          _NS_COUNT_HACK(69); _NS_COUNT_HACK(70); _NS_COUNT_HACK(71);
Current language:  auto; currently minimal
(gdb) bt
#0  0x05004dc2 in NSCountFrames () at NSDebug.m:1005
#1  0x0500c5d3 in GSPrivateStackAddresses () at NSDebug.m:1112
#2  0x05023d31 in -[GSStackTrace init] (self=0x7e1467a8, _cmd=0x24fff508) at 
NSException.m:605
#3  0x050779f0 in +[NSObject new] (self=0x24fe6280, _cmd=0x24fe6300) at 
NSObject.m:1159
#4  0x05024b19 in -[NSException raise] (self=0x7e146a08, _cmd=0x24fe6368) at 
NSException.m:960
#5  0x050241db in +[NSException raise:format:arguments:] (self=0x24fe6180, 
_cmd=0x24fe6350, name=0x3c006000, 
    format=0x3c00600c, argList=0xcfbce840 "") at NSException.m:849
#6  0x05024113 in +[NSException raise:format:] (self=0x24fe6180, 
_cmd=0x3c006648, name=0x3c006000, format=0x3c00600c)
    at NSException.m:835
#7  0x1c007501 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:423
#8  0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#9  0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#10 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#11 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#12 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#13 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#14 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#15 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#16 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#17 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#18 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#19 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#20 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#21 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#22 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#23 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#24 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#25 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#26 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#27 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#28 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#29 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#30 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#31 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#32 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#33 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#34 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#35 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#36 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#37 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#38 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#39 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#40 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#41 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#42 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#43 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#44 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#45 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#46 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#47 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#48 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#49 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#50 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#51 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#52 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#53 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#54 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#55 0x1c0078b5 in -[Sudoku doFind:] (self=0x815c3008, _cmd=0x3c006628, 
seen=0x7f132008) at Sudoku.m:487
#56 0x1c00726a in -[Sudoku find] (self=0x815c3008, _cmd=0x3c002468) at 
Sudoku.m:371
#57 0x1c001eef in -[Controller newPuzzle:] (self=0x83730f48, _cmd=0x3c0089f8, 
sender=0x8bfec088) at Controller.m:110
#58 0x036fd009 in -[NSApplication sendAction:to:from:] (self=0x85ad2c88, 
_cmd=0x236aa5f8, aSelector=0x3c0089f8, aTarget=0x0, 
    sender=0x8bfec088) at NSApplication.m:2259
#59 0x037d3380 in -[NSMenu performActionForItemAtIndex:] (self=0x7d11bf08, 
_cmd=0x236ad100, index=2) at NSMenu.m:1320
#60 0x037ddd59 in -[NSMenuView _trackWithEvent:] (self=0x8bedba08, 
_cmd=0x236ad188, event=0x7f7ec288) at NSMenuView.m:1785
#61 0x037dde3c in -[NSMenuView trackWithEvent:] (self=0x8bedba08, 
_cmd=0x236ad1d8, event=0x854e0d88) at NSMenuView.m:1808
#62 0x037de00b in -[NSMenuView mouseDown:] (self=0x8bedba08, _cmd=0x23706df0, 
theEvent=0x854e0d88) at NSMenuView.m:1847
#63 0x038c71e1 in -[NSWindow sendEvent:] (self=0x8bc23e08, _cmd=0x2365b690, 
theEvent=0x854e0d88) at NSWindow.m:3694
#64 0x036fcaa8 in -[NSApplication sendEvent:] (self=0x85ad2c88, 
_cmd=0x2365b5c8, theEvent=0x854e0d88) at NSApplication.m:2134
#65 0x036fb223 in -[NSApplication run] (self=0x85ad2c88, _cmd=0x23650d80) at 
NSApplication.m:1591
#66 0x036d8d8f in NSApplicationMain (argc=1, argv=0xcfbd47f8) at Functions.m:89
#67 0x1c00bac0 in gnustep_base_user_main (argc=1, argv=0xcfbd47f8, 
env=0xcfbd4800) at main.m:168
#68 0x050a1ad4 in main (argc=1, argv=0xcfbd47f8, env=0xcfbd4800) at 
NSProcessInfo.m:979
#69 0x1c001507 in ___start ()
#70 0x1c001487 in _start ()
#71 0x00000000 in ?? ()
#0  0x05004dc2 in NSCountFrames () at NSDebug.m:1005
1005          _NS_COUNT_HACK(69); _NS_COUNT_HACK(70); _NS_COUNT_HACK(71);
(gdb) list
1000          _NS_COUNT_HACK(54); _NS_COUNT_HACK(55); _NS_COUNT_HACK(56);
1001          _NS_COUNT_HACK(57); _NS_COUNT_HACK(58); _NS_COUNT_HACK(59);
1002          _NS_COUNT_HACK(60); _NS_COUNT_HACK(61); _NS_COUNT_HACK(62);
1003          _NS_COUNT_HACK(63); _NS_COUNT_HACK(64); _NS_COUNT_HACK(65);
1004          _NS_COUNT_HACK(66); _NS_COUNT_HACK(67); _NS_COUNT_HACK(68);
1005          _NS_COUNT_HACK(69); _NS_COUNT_HACK(70); _NS_COUNT_HACK(71);
1006          _NS_COUNT_HACK(72); _NS_COUNT_HACK(73); _NS_COUNT_HACK(74);
1007          _NS_COUNT_HACK(75); _NS_COUNT_HACK(76); _NS_COUNT_HACK(77);
1008          _NS_COUNT_HACK(78); _NS_COUNT_HACK(79); _NS_COUNT_HACK(80);
1009          _NS_COUNT_HACK(81); _NS_COUNT_HACK(82); _NS_COUNT_HACK(83);
(gdb) frame 4
#4  0x05024b19 in -[NSException raise] (self=0x7e146a08, _cmd=0x24fe6368) at 
NSException.m:960
960       _e_stack = [GSStackTrace new];
(gdb) list
955     {
956       if (_reserved == 0)
957         {
958           _reserved = NSZoneCalloc([self zone], 2, sizeof(id));
959         }
960       _e_stack = [GSStackTrace new];
961
962     #if     defined(_NATIVE_OBJC_EXCEPTIONS)
963       @throw self;
964     #else

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 (:

cheers,
Sebastian



reply via email to

[Prev in Thread] Current Thread [Next in Thread]