New crash on MacOS with LWJGL2

Started by princec, October 09, 2019, 18:54:49

Previous topic - Next topic

princec

Game (Ultratron) runs for a short while on Catalina then crashes:

Date/Time:             2019-10-09 11:21:15.399 -0700
OS Version:            Mac OS X 10.15 (19A583)
Report Version:        12
Bridge OS Version:     4.0 (17P572)

System Integrity Protection: enabled

Crashed Thread:        2

Exception Type:        EXC_BAD_INSTRUCTION (SIGABRT)
Exception Codes:       0x0000000000000001, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Application Specific Information:
Refcount overflow in NSResponder or subclass. Too many unbalanced -retains!

...

Thread 2 Crashed:
0   libsystem_kernel.dylib        	0x00007fff6d88147a __pthread_kill + 10
1   libsystem_pthread.dylib       	0x00007fff6d93e707 pthread_kill + 384
2   libsystem_c.dylib             	0x00007fff6d809a08 abort + 120
3   libjvm.dylib                  	0x000000010d297bbb os::abort(bool) + 25
4   libjvm.dylib                  	0x000000010d3c195e VMError::report_and_die() + 2388
5   libjvm.dylib                  	0x000000010d29980a JVM_handle_bsd_signal + 1131
6   libjvm.dylib                  	0x000000010d29599b signalHandler(int, __siginfo*, void*) + 47
7   libsystem_platform.dylib      	0x00007fff6d933b1d _sigtramp + 29
8   ???                           	0x0000700004daf308 0 + 123145383768840
9   libobjc.A.dylib               	0x00007fff6c3ce19d objc_loadWeakRetained + 351
10  libobjc.A.dylib               	0x00007fff6c3cfddc objc_loadWeak + 15
11  com.apple.AppKit              	0x00007fff336d2bb4 -[NSWindow firstResponder] + 22
12  liblwjgl.dylib                	0x0000000115fe8b17 Java_org_lwjgl_opengl_MacOSXDisplay_nIsFocused + 103
13  ???                           	0x00000001164d263c 0 + 4669122108


Anyone else come across this one yet?

Cas :)

kappa

Having a quick look it appears this error is triggered by the call to LWJGL2's Display.isActive() method.

From the crash stack it originates from the native call Java_org_lwjgl_opengl_MacOSXDisplay_nIsFocused, which is composed of two checks to NSWindow methods (isKeyWindow & firstResponder):

return (jboolean)([[window_info->view window] isKeyWindow] && [[window_info->view window] firstResponder] == window_info->view);


Thereafter the stack shows the crash originates from within the call to [NSWindow firstResponder].

I can't really see any memory management going on in the LWJGL code that would cause the overflow. Therefore the crash appears to be originating from inside the firstResponder method. If it doesn't happen in previous versions of MacOS, I'm guessing its probably an OS bug or some sort of change in behaviour in how that method worked.

From just looking at the LWJGL code (so not 100% sure) I don't think the check for "&& [[window_info->view window] firstResponder] == window_info->view" is even needed for a stand-alone LWJGL Display window and is probably there for checking if the Display.isActive() when embedded inside an AWT window. So a quick hack/workaround without looking further at the cause of the overflow may be to just disable this additional check (inside org_lwjgl_opengl_Display.m) if there is no parent window (AWT Parent), therefore avoiding the call to the firstResponder method altogether.

In the long term, you really should make the switch to LWJGL3. LWJGL2 being unmaintained (surprising it still works as much as it does) is only going to get more and more broken (especially on Mac's as Apple make regular changes to their API's).

princec

I would do except this is old code and I'd really rather not ever see it ever again as it doesn't make me any money...

Cas :)

VladimirN

Got a similar crash:

"I can't really see any memory management going on in the LWJGL code that would cause the overflow." The same case =(

https://stackoverflow.com/questions/59141491/nsresponder-tryretain-crash

princec

I'm certain it's a new bug in the OS itself. It's the last straw for MacOS for me really... I can't afford a new Mac to make and test builds on.

Cas :)

VladimirN

In my case, I got such crashes from users =(

I can't reproduce it on my mac too.

If someone manages to do reproduce. Could you please report a bug to https://feedbackassistant.apple.com/ and let us know what they have answered?

I have 10.15, please, let me know if you have the exact scenario.(I'll try to reproduce and report too)

Thanks in advance.

VladimirN

Finally, I did find the "reason" and the "solution". https://stackoverflow.com/questions/59141491/nsresponder-tryretain-crash

Please, let me know if there is any news.