discuss-gnustep
[Top][All Lists]
Advanced

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

Re: Mysterious crash in NSRunLoop, using libobjc2 on Linux


From: Lobron, David
Subject: Re: Mysterious crash in NSRunLoop, using libobjc2 on Linux
Date: Wed, 6 Dec 2017 19:04:29 +0000

> I’m not sure why you’re seeing a call to _Unwind_Resume from NS_ENDHANDLER.  
> It looks as if you have some cleanup code in that block that is being run 
> when you throw the exception from the -raise method.  Actually, this entire 
> block looks fragile and redundant - what happens if you simply delete the 
> entire EH block here?  Exception objects are retained / released by the 
> runtime, so don’t need special handling to propagate past autoreleasepool 
> boundaries.  

I did some more sleuthing, and I realized the reason this unit test is special: 
it has an invalid tree symbol which prompts an exception.  With the gcc build 
and runtime, that exception is caught, but with clang/libobjc2, the stack 
unwinds after the exception and then abort is called partway through the 
unwind.  I removed the NS_HANDLER block from my code, as you suggested above, 
but that did not appear to have any effect on the behavior.  However, I 
followed the breakpoints on _Unwind_Resume, and I traced the entire process:

The initial exception is thrown where I would expect, at the point where the 
tree parser hits the invalid symbol.  The stack at that point is:

#0  -[NSException raise] (self=0x17151c80, _cmd=0x7ffff617a070 
<.objc_selector_list+64>) at NSException.m:1137
#1  0x00007ffff5cc5a80 in +[NSException raise:format:] (self=0x17151c80, 
_cmd=<optimized out>, name=0xa447668, format=0x59d34) at NSException.m:1016
#2  0x00000000004d2765 in parsePingTreeSymbol(NSString*, void*) 
(symbol=0xa470340, context=0x2e0f690) at PingState.mm:83
#3  0x00007ffff6f28ec4 in -[RadixTree 
initWithFileDescriptor:symbolParserFunction:context:] (self=0x391e, 
_cmd=<optimized out>, fd=<optimized out>, 
    parser=0x4d2430 <parsePingTreeSymbol(NSString*, void*)>, context=0x2e0f690) 
at RadixTree.mm:827
#4  0x00000000004d23e7 in -[PingTreeParser pingTreeWithFile:] (self=0x0, 
_cmd=<optimized out>, path=0xa447668) at PingState.mm:305
#5  0x00007ffff6ecd777 in -[FileAcceptor checkForObject] (self=0x319f220, 
_cmd=<optimized out>) at FileAcceptor.m:630
#6  0x00000000004ccd1c in PingScoresRebaser::rebase() (this=0x3596570) at 
PingScoresRebaser.mm:208
#7  0x00000000004c302b in RebaserProxy<PingScoresRebaser>::rebase() 
(this=<optimized out>) at ./RebaserProxy.h:202
#8  0x00000000004c1cc7 in RebaserProxy<PingScoresRebaser>::operator->() 
(this=0xfc6db0) at ./RebaserProxy.h:262
#9  0x00000000004bdaaa in -[MapMaker readNewInputs] (self=0xb65e40, 
_cmd=<optimized out>) at MapMaker.mm:1708
#10 0x00000000004bdbbd in -[MapMaker readInputsAndMakeMap] (self=0xb65e40, 
_cmd=<optimized out>) at MapMaker.mm:1739
#11 0x00000000004bee29 in -[MapMaker doWork] (self=0xb65e40, _cmd=<optimized 
out>) at MapMaker.mm:2017
#12 0x00007ffff6e9cd16 in -[AkamaiDaemon(PrivateMethods) doOneCycle:] 
(self=0xb65e40, _cmd=<optimized out>, ignored=<optimized out>) at 
AkamaiDaemon.m:467
#13 0x00007ffff5d59837 in -[NSTimer fire] (self=0x1017260, _cmd=<optimized 
out>) at NSTimer.m:283
#14 0x00007ffff5d34029 in -[NSRunLoop _limitDateForContext:] (self=0xe0e510, 
_cmd=<optimized out>, context=0xe23600) at NSRunLoop.m:1011
#15 0x00007ffff5d34468 in -[NSRunLoop limitDateForMode:] (self=0xe0e510, 
_cmd=0x7ffff61b3d18 <.objc_selector_list+96>, mode=0x7ffff61b2e38 <.objc_str>)
    at NSRunLoop.m:1111
#16 0x00007ffff5d34c26 in -[NSRunLoop runMode:beforeDate:] (self=0xe0e510, 
_cmd=0x7ffff61b3d88 <.objc_selector_list+208>, mode=0x7ffff61b2e38 <.objc_str>, 
    date=0xfb2b90) at NSRunLoop.m:1285
#17 0x00007ffff5d34d31 in -[NSRunLoop runUntilDate:] (self=0xe0e510, 
_cmd=<optimized out>, date=0xfb2b90) at NSRunLoop.m:1334
#18 0x00007ffff6e9f1ec in -[AkamaiDaemon mainLoop] (self=0xb65e40, 
_cmd=<optimized out>) at AkamaiDaemon.m:1080
#19 0x00000000004c4c09 in main (argc=<optimized out>, argv=<optimized out>) at 
MapMakerMainFunc.mm:29

When I continue from here, the next breakpoint to hit is the one on 
_Unwind_Resume:

#0  _Unwind_Resume (exc=0x171607d0) at ../../../src/libgcc/unwind.inc:224
#1  0x00007ffff6f29259 in -[RadixTree 
initWithFileDescriptor:symbolParserFunction:context:] (self=0x391e, 
_cmd=<optimized out>, fd=<optimized out>, 
    parser=0x4d2430 <parsePingTreeSymbol(NSString*, void*)>, context=0x2e0f690) 
at 
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ext/new_allocator.h:110
#2  0x00000000004d23e7 in -[PingTreeParser pingTreeWithFile:] 
(self=0x7fffffffb998, _cmd=<optimized out>, path=0x0) at PingState.mm:305
#3  0x00007ffff6ecd777 in -[FileAcceptor checkForObject] (self=0x319f220, 
_cmd=<optimized out>) at FileAcceptor.m:630
#4  0x00000000004ccd1c in PingScoresRebaser::rebase() (this=0x3596570) at 
PingScoresRebaser.mm:208
#5  0x00000000004c302b in RebaserProxy<PingScoresRebaser>::rebase() 
(this=<optimized out>) at ./RebaserProxy.h:202
#6  0x00000000004c1cc7 in RebaserProxy<PingScoresRebaser>::operator->() 
(this=0xfc6db0) at ./RebaserProxy.h:262
#7  0x00000000004bdaaa in -[MapMaker readNewInputs] (self=0xb65e40, 
_cmd=<optimized out>) at MapMaker.mm:1708
#8  0x00000000004bdbbd in -[MapMaker readInputsAndMakeMap] (self=0xb65e40, 
_cmd=<optimized out>) at MapMaker.mm:1739
#9  0x00000000004bee29 in -[MapMaker doWork] (self=0xb65e40, _cmd=<optimized 
out>) at MapMaker.mm:2017
#10 0x00007ffff6e9cd16 in -[AkamaiDaemon(PrivateMethods) doOneCycle:] 
(self=0xb65e40, _cmd=<optimized out>, ignored=<optimized out>) at 
AkamaiDaemon.m:467
#11 0x00007ffff5d59837 in -[NSTimer fire] (self=0x1017260, _cmd=<optimized 
out>) at NSTimer.m:283
#12 0x00007ffff5d34029 in -[NSRunLoop _limitDateForContext:] (self=0xe0e510, 
_cmd=<optimized out>, context=0xe23600) at NSRunLoop.m:1011
#13 0x00007ffff5d34468 in -[NSRunLoop limitDateForMode:] (self=0xe0e510, 
_cmd=0x7ffff61b3d18 <.objc_selector_list+96>, mode=0x7ffff61b2e38 <.objc_str>)
    at NSRunLoop.m:1111
#14 0x00007ffff5d34c26 in -[NSRunLoop runMode:beforeDate:] (self=0xe0e510, 
_cmd=0x7ffff61b3d88 <.objc_selector_list+208>, mode=0x7ffff61b2e38 <.objc_str>, 
    date=0xfb2b90) at NSRunLoop.m:1285
#15 0x00007ffff5d34d31 in -[NSRunLoop runUntilDate:] (self=0xe0e510, 
_cmd=<optimized out>, date=0xfb2b90) at NSRunLoop.m:1334
#16 0x00007ffff6e9f1ec in -[AkamaiDaemon mainLoop] (self=0xb65e40, 
_cmd=<optimized out>) at AkamaiDaemon.m:1080
#17 0x00000000004c4c09 in main (argc=<optimized out>, argv=<optimized out>) at 
MapMakerMainFunc.mm:29

Continuing, the _Unwind_Resume is hit several more times as the stack unwinds:

#0  _Unwind_Resume (exc=0x171607d0) at ../../../src/libgcc/unwind.inc:224
#1  0x00007ffff6ecd8a0 in -[FileAcceptor checkForObject] (self=0x319f220, 
_cmd=<optimized out>) at FileAcceptor.m:639
#2  0x00000000004ccd1c in PingScoresRebaser::rebase() (this=0x3596570) at 
PingScoresRebaser.mm:208
#3  0x00000000004c302b in RebaserProxy<PingScoresRebaser>::rebase() 
(this=<optimized out>) at ./RebaserProxy.h:202
#4  0x00000000004c1cc7 in RebaserProxy<PingScoresRebaser>::operator->() 
(this=0xfc6db0) at ./RebaserProxy.h:262
#5  0x00000000004bdaaa in -[MapMaker readNewInputs] (self=0xb65e40, 
_cmd=<optimized out>) at MapMaker.mm:1708
#6  0x00000000004bdbbd in -[MapMaker readInputsAndMakeMap] (self=0xb65e40, 
_cmd=<optimized out>) at MapMaker.mm:1739
#7  0x00000000004bee29 in -[MapMaker doWork] (self=0xb65e40, _cmd=<optimized 
out>) at MapMaker.mm:2017
#8  0x00007ffff6e9cd16 in -[AkamaiDaemon(PrivateMethods) doOneCycle:] 
(self=0xb65e40, _cmd=<optimized out>, ignored=<optimized out>) at 
AkamaiDaemon.m:467
#9  0x00007ffff5d59837 in -[NSTimer fire] (self=0x1017260, _cmd=<optimized 
out>) at NSTimer.m:283
#10 0x00007ffff5d34029 in -[NSRunLoop _limitDateForContext:] (self=0xe0e510, 
_cmd=<optimized out>, context=0xe23600) at NSRunLoop.m:1011
#11 0x00007ffff5d34468 in -[NSRunLoop limitDateForMode:] (self=0xe0e510, 
_cmd=0x7ffff61b3d18 <.objc_selector_list+96>, mode=0x7ffff61b2e38 <.objc_str>)
    at NSRunLoop.m:1111
#12 0x00007ffff5d34c26 in -[NSRunLoop runMode:beforeDate:] (self=0xe0e510, 
_cmd=0x7ffff61b3d88 <.objc_selector_list+208>, mode=0x7ffff61b2e38 <.objc_str>, 
    date=0xfb2b90) at NSRunLoop.m:1285
#13 0x00007ffff5d34d31 in -[NSRunLoop runUntilDate:] (self=0xe0e510, 
_cmd=<optimized out>, date=0xfb2b90) at NSRunLoop.m:1334
#14 0x00007ffff6e9f1ec in -[AkamaiDaemon mainLoop] (self=0xb65e40, 
_cmd=<optimized out>) at AkamaiDaemon.m:1080
#15 0x00000000004c4c09 in main (argc=<optimized out>, argv=<optimized out>) at 
MapMakerMainFunc.mm:29


#0  _Unwind_Resume (exc=0x171607d0) at ../../../src/libgcc/unwind.inc:224
#1  0x00000000004bdb96 in -[MapMaker readNewInputs] (self=0xb65e40, 
_cmd=<optimized out>) at MapMaker.mm:1721
#2  0x00000000004bdbbd in -[MapMaker readInputsAndMakeMap] (self=0xb65e40, 
_cmd=<optimized out>) at MapMaker.mm:1739
#3  0x00000000004bee29 in -[MapMaker doWork] (self=0xb65e40, _cmd=<optimized 
out>) at MapMaker.mm:2017
#4  0x00007ffff6e9cd16 in -[AkamaiDaemon(PrivateMethods) doOneCycle:] 
(self=0xb65e40, _cmd=<optimized out>, ignored=<optimized out>) at 
AkamaiDaemon.m:467
#5  0x00007ffff5d59837 in -[NSTimer fire] (self=0x1017260, _cmd=<optimized 
out>) at NSTimer.m:283
#6  0x00007ffff5d34029 in -[NSRunLoop _limitDateForContext:] (self=0xe0e510, 
_cmd=<optimized out>, context=0xe23600) at NSRunLoop.m:1011
#7  0x00007ffff5d34468 in -[NSRunLoop limitDateForMode:] (self=0xe0e510, 
_cmd=0x7ffff61b3d18 <.objc_selector_list+96>, mode=0x7ffff61b2e38 <.objc_str>)
    at NSRunLoop.m:1111
#8  0x00007ffff5d34c26 in -[NSRunLoop runMode:beforeDate:] (self=0xe0e510, 
_cmd=0x7ffff61b3d88 <.objc_selector_list+208>, mode=0x7ffff61b2e38 <.objc_str>, 
    date=0xfb2b90) at NSRunLoop.m:1285
#9  0x00007ffff5d34d31 in -[NSRunLoop runUntilDate:] (self=0xe0e510, 
_cmd=<optimized out>, date=0xfb2b90) at NSRunLoop.m:1334
#10 0x00007ffff6e9f1ec in -[AkamaiDaemon mainLoop] (self=0xb65e40, 
_cmd=<optimized out>) at AkamaiDaemon.m:1080
#11 0x00000000004c4c09 in main (argc=<optimized out>, argv=<optimized out>) at 
MapMakerMainFunc.mm:29


#0  _Unwind_Resume (exc=0x171607d0) at ../../../src/libgcc/unwind.inc:224
#1  0x00007ffff6e9ce10 in -[AkamaiDaemon(PrivateMethods) doOneCycle:] 
(self=0xb65e40, _cmd=<optimized out>, ignored=<optimized out>) at 
AkamaiDaemon.m:470
#2  0x00007ffff5d59837 in -[NSTimer fire] (self=0x1017260, _cmd=<optimized 
out>) at NSTimer.m:283
#3  0x00007ffff5d34029 in -[NSRunLoop _limitDateForContext:] (self=0xe0e510, 
_cmd=<optimized out>, context=0xe23600) at NSRunLoop.m:1011
#4  0x00007ffff5d34468 in -[NSRunLoop limitDateForMode:] (self=0xe0e510, 
_cmd=0x7ffff61b3d18 <.objc_selector_list+96>, mode=0x7ffff61b2e38 <.objc_str>)
    at NSRunLoop.m:1111
#5  0x00007ffff5d34c26 in -[NSRunLoop runMode:beforeDate:] (self=0xe0e510, 
_cmd=0x7ffff61b3d88 <.objc_selector_list+208>, mode=0x7ffff61b2e38 <.objc_str>, 
    date=0xfb2b90) at NSRunLoop.m:1285
#6  0x00007ffff5d34d31 in -[NSRunLoop runUntilDate:] (self=0xe0e510, 
_cmd=<optimized out>, date=0xfb2b90) at NSRunLoop.m:1334
#7  0x00007ffff6e9f1ec in -[AkamaiDaemon mainLoop] (self=0xb65e40, 
_cmd=<optimized out>) at AkamaiDaemon.m:1080
#8  0x00000000004c4c09 in main (argc=<optimized out>, argv=<optimized out>) at 
MapMakerMainFunc.mm:29


#0  _Unwind_Resume (exc=0x171607d0) at ../../../src/libgcc/unwind.inc:224
#1  0x00007ffff5d599ac in -[NSTimer fire] (self=0x1017260, _cmd=<optimized 
out>) at NSTimer.m:287
#2  0x00007ffff5d34029 in -[NSRunLoop _limitDateForContext:] (self=0xe0e510, 
_cmd=<optimized out>, context=0xe23600) at NSRunLoop.m:1011
#3  0x00007ffff5d34468 in -[NSRunLoop limitDateForMode:] (self=0xe0e510, 
_cmd=0x7ffff61b3d18 <.objc_selector_list+96>, mode=0x7ffff61b2e38 <.objc_str>)
    at NSRunLoop.m:1111
#4  0x00007ffff5d34c26 in -[NSRunLoop runMode:beforeDate:] (self=0xe0e510, 
_cmd=0x7ffff61b3d88 <.objc_selector_list+208>, mode=0x7ffff61b2e38 <.objc_str>, 
    date=0xfb2b90) at NSRunLoop.m:1285
#5  0x00007ffff5d34d31 in -[NSRunLoop runUntilDate:] (self=0xe0e510, 
_cmd=<optimized out>, date=0xfb2b90) at NSRunLoop.m:1334
#6  0x00007ffff6e9f1ec in -[AkamaiDaemon mainLoop] (self=0xb65e40, 
_cmd=<optimized out>) at AkamaiDaemon.m:1080
#7  0x00000000004c4c09 in main (argc=<optimized out>, argv=<optimized out>) at 
MapMakerMainFunc.mm:29


#0  _Unwind_Resume (exc=0x171607d0) at ../../../src/libgcc/unwind.inc:224
#1  0x00007ffff5d34555 in -[NSRunLoop limitDateForMode:] (self=0xe0e510, 
_cmd=0x7ffff61b3d18 <.objc_selector_list+96>, mode=0x7ffff61b2e38 <.objc_str>)
    at NSRunLoop.m:1119
#2  0x00007ffff5d34c26 in -[NSRunLoop runMode:beforeDate:] (self=0xe0e510, 
_cmd=0x7ffff61b3d88 <.objc_selector_list+208>, mode=0x7ffff61b2e38 <.objc_str>, 
    date=0xfb2b90) at NSRunLoop.m:1285
#3  0x00007ffff5d34d31 in -[NSRunLoop runUntilDate:] (self=0xe0e510, 
_cmd=<optimized out>, date=0xfb2b90) at NSRunLoop.m:1334
#4  0x00007ffff6e9f1ec in -[AkamaiDaemon mainLoop] (self=0xb65e40, 
_cmd=<optimized out>) at AkamaiDaemon.m:1080
#5  0x00000000004c4c09 in main (argc=<optimized out>, argv=<optimized out>) at 
MapMakerMainFunc.mm:29


But then, abort is called when it tries to unwind past limitDateForMode:

#0  __GI_abort () at abort.c:51
#1  0x00007ffff4f70521 in _Unwind_Resume (exc=0x171607d0) at 
../../../src/libgcc/unwind.inc:234
#2  0x00007ffff5d34555 in -[NSRunLoop limitDateForMode:] (self=0xe0e510, 
_cmd=0x7ffff61b3d18 <.objc_selector_list+96>, mode=0x7ffff61b2e38 <.objc_str>)
    at NSRunLoop.m:1119
#3  0x00007ffff5d34c26 in -[NSRunLoop runMode:beforeDate:] (self=0xe0e510, 
_cmd=0x7ffff61b3d88 <.objc_selector_list+208>, mode=0x7ffff61b2e38 <.objc_str>, 
    date=0xfb2b90) at NSRunLoop.m:1285
#4  0x00007ffff5d34d31 in -[NSRunLoop runUntilDate:] (self=0xe0e510, 
_cmd=<optimized out>, date=0xfb2b90) at NSRunLoop.m:1334
#5  0x00007ffff6e9f1ec in -[AkamaiDaemon mainLoop] (self=0xb65e40, 
_cmd=<optimized out>) at AkamaiDaemon.m:1080
#6  0x00000000004c4c09 in main (argc=<optimized out>, argv=<optimized out>) at 
MapMakerMainFunc.mm:29

So the question is: why is abort being called here?  Why doesn't the stack 
continue to unwind?  I did notice that certain frames seem to be skipped in the 
unwind sequence above, and the line numbers reported do change a little - could 
that be related to the problem?  I'm linking with libunwind-1.1, and I'm 
building it with a fairly standard set of options (copied below). 

--David

cd /home/dlobron/build/clangport/akamai/libunwind/libunwind-1.1 && setarch 
x86_64 ./configure --enable-static --disable-shared 
--prefix=/home/dlobron/build/clangport/akamai/libunwind/INSTALLED 
--libdir=/home/dlobron/build/clangport/akamai/common/lib 
--includedir=/home/dlobron/build/clangport/akamai/common/include/libunwind 
--disable-cxx-exceptions --disable-minidebuginfo --build=x86_64-pc-linux-gnu 
--target=x86_64-pc-linux-gnu  
CC="/home/dlobron/build/clangport/akamai/llvm/llvm-5.0.0.install/bin/clang" 
CPP="/home/dlobron/build/clangport/akamai/llvm/llvm-5.0.0.install/bin/clang -E" 
CXX="/home/dlobron/build/clangport/akamai/llvm/llvm-5.0.0.install/bin/clang++" 
CFLAGS="-m64 -march=opteron -mno-3dnow -ggdb -O2 -Wall -fPIC -U_FORTIFY_SOURCE 
-I/home/dlobron/build/clangport/akamai/libunwind" 
CPPFLAGS="-I/home/dlobron/build/clangport/akamai/common/include 
-I/usr/local/include" CXXFLAGS="-m64 -march=opteron -mno-3dnow -ggdb -O2 -fPIC" 
LDFLAGS="-L/home/dlobron/build/clangport/akamai/common/lib -m64 "



reply via email to

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