gnustep-dev
[Top][All Lists]
Advanced

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

Re: Crash on Linux+Clang (NSTimer)


From: David Chisnall
Subject: Re: Crash on Linux+Clang (NSTimer)
Date: Mon, 9 Nov 2020 09:58:30 +0000
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0

Hi Riccardo,

Nothing there looks obviously wrong, but the fact that you're getting a SEGV on an line that isn't explicitly accessing memory is interesting, as is the fact that this is in a `+initialize` method.

I wonder if the code in `objc_msgSend` is leaving the stack incorrectly aligned? I encountered a similar problem with some assembly trampolines in another project recently, where everything was fine 99% of the time, but in a few cases the compiler was using SSE instructions on the stack and was crashing because the stack pointer was only 8-byte aligned and not the ABI-mandated 16-byte aligned.

If this is the case, you'll be able to see by looking at the value of the %rsp register and the current instruction. Please can you:

- Use `show registers rsp` to let me know your current stack pointer value.
 - Use `disas` and show me the instruction that it points to

For extra confirmation, put an breakpoint on the first instruction of `NSRunLoop`'s `+initialize` and let me know what the value of %rsp is on function entry?

Looking at the code, I think we are spilling 24 8-byte words to the stack, but the weirdness related to the x86 call instruction means that we will be doing the wrong thing for the ABI.

If you want to try a fix, I believe changing the 0x98 to 0xa0 on these two lines should work:

https://github.com/gnustep/libobjc2/blob/41808111aa0a58708daf66b2322940d4353e37d8/objc_msgSend.x86-64.S#L216

https://github.com/gnustep/libobjc2/blob/41808111aa0a58708daf66b2322940d4353e37d8/objc_msgSend.x86-64.S#L257

I believe doing that should cause the objc_msgSend test in the runtime's test suite to fail, but then changing the 0xD8 to 0xE0 on this line should fix it:

https://github.com/gnustep/libobjc2/blob/41808111aa0a58708daf66b2322940d4353e37d8/objc_msgSend.x86-64.S#L241

David

On 08/11/2020 22:44, Riccardo Mottola wrote:
HI,


I just recompiled all GNUstep on Linux-x86/clang+libobjc2

libobjc2 is linked with the gold linker, clang is 10.0 - so every pretty new!

Any GUI apps crashes (things pliek plparse, plmerge do run)


Starting program: /Local/Tools/Ink
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0xb7850558 in -[NSTimer initWithFireDate:interval:target:selector:userInfo:repeats:] (self=0x834c2f4,     _cmd=0xb7b2ce94 <.objc_selector_initWithFireDate:interval:target:selector:userInfo:repeats:_360:48d1220:2428C32>,     fd=0x0, ti=30, object=0x833f434, selector=0x0, info=0x0, f=1 '\001') at NSTimer.m:119
119      if (ti <= 0.0)


#0  0xb7850558 in -[NSTimer initWithFireDate:interval:target:selector:userInfo:repeats:] (self=0x834c2f4,     _cmd=0xb7b2ce94 <.objc_selector_initWithFireDate:interval:target:selector:us#17 0xb7c022c6 in NSApplicationMain (argc=<optimized out>, argv=<optimized out>) at Functions.m:87 #18 0x08049200 in main (argc=<optimized out>, argv=<optimized out>, env=<optimized out>) at main.m:30
erInfo:repeats:_360:48d1220:2428C32>,
    fd=0x0, ti=30, object=0x833f434, selector=0x0, info=0x0, f=1 '\001') at NSTimer.m:119 #1  0xb7822d56 in +[NSRunLoop _runLoopForThread:] (self=<optimized out>, _cmd=<optimized out>, aThread=<optimized out>)
     at NSRunLoop.m:785
#2  0xb7822db5 in +[NSRunLoop currentRunLoop] (self=<optimized out>, _cmd=<optimized out>) at NSRunLoop.m:812 #3  0xb7822b36 in +[NSRunLoop initialize] (self=<optimized out>, _cmd=<optimized out>) at NSRunLoop.m:748 #4  0xb75f0fcd in objc_send_initialize () from /System/Library/Libraries/libobjc.so.4.6 #5  0xb75fca25 in slowMsgLookup () from /System/Library/Libraries/libobjc.so.4.6 #6  0xb7602951 in objc_msgSend () from /System/Library/Libraries/libobjc.so.4.6 #7  0xb45d12ba in -[XGServer(EventOps) setupRunLoopInputSourcesForMode:] (self=<optimized out>, _cmd=<optimized out>,
     mode=<optimized out>) at XGServerEvent.m:231
#8  0xb45d02e1 in -[XGServer initWithAttributes:] (self=<optimized out>, _cmd=<optimized out>, info=<optimized out>)     at XGServer.m:493#17 0xb7c022c6 in NSApplicationMain (argc=<optimized out>, argv=<optimized out>) at Functions.m:87 #18 0x08049200 in main (argc=<optimized out>, argv=<optimized out>, env=<optimized out>) at main.m:30

#9  0xb7d84e02 in +[GSDisplayServer serverWithAttributes:] (self=<optimized out>, _cmd=<optimized out>,
     attributes=<optimized out>) at GSDisplayServer.m:181
#10 0xb7c19ac1 in -[NSApplication _init] (self=<optimized out>, _cmd=<optimized out>) at NSApplication.m:892 #11 0xb77ecada in -[NSObject performSelector:withObject:] (self=<optimized out>, _cmd=<optimized out>,     aSelector=<optimized out>, anObje$ ./configure --prefix=/ --with-layout=gnustep --with-library-combo=ng-gnu-gnu ct=<optimized out>) at NSObject.m:2027 #12 0xb784fe4d in -[NSObject(NSThreadPerformAdditions) performSelector:onThread:withObject:waitUntilDone:modes:] (     self=<optimized out>, _cmd=<optimized out>, aSelector=<optimized out>, aThread=0x8157bb4, anObject=<optimized out>,
     aFlag=<optimized out>, anArray=<optimized out>) at NSThread.m:2168
#13 0xb784fa1c in -[NSObject(NSThreadPerformAdditions) performSelectorOnMainThread:withObject:waitUntilDone:modes:] (     self=<optimized out>, _cmd=<optimized out>, aSelector=<optimized out>, anObject=<optimized out>, aFlag=<optimized out>,
     anArray=<optimized out>) at NSThread.m:2123
#14 0xb784fb6f in -[NSObject(NSThreadPerformAdditions) performSelectorOnMainThread:withObject:waitUntilDone:] (     self=<optimized out>, _cmd=<optimized out>, aSelector=<optimized out>, anObject=<optimized out>, aFlag=<optimized out>)$ ./configure --prefix=/ --with-layout=gnustep --with-library-combo=ng-gnu-gnu
     at NSThread.m:2134
#15 0xb7c1a00d in -[NSApplication init] (self=<optimized out>, _cmd=<optimized out>) at NSApplication.m:986 #16 0xb7c19a4e in +[NSApplication sharedApplication] (self=<optimized out>, _cmd=<optimized out>) at NSApplication.m:858 #17 0xb7c022c6 in NSApplicationMain (argc=<optimized out>, argv=<optimized out>) at Functions.m:87 #18 0x08049200 in main (argc=<optimized out>, argv=<optimized out>, env=<optimized out>) at main.m:30


I remember reporting this months ago.. in March, then I was probably using an older version of clang, but nothing improved since then. This is my "Linux/clang/libobjc2" setup test.... just to not always use gcc :) :)

$ ./configure --prefix=/ --with-layout=gnustep --with-library-combo=ng-gnu-gnu


Any ideas? I don't see I did anything "wrong" or special here.


Riccardo





reply via email to

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