My app crashes under High Sierra in WaitWindowEvent()

Mac OSX specific forum
User avatar
Kukulkan
Addict
Addict
Posts: 1352
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

My app crashes under High Sierra in WaitWindowEvent()

Post by Kukulkan »

Hi,

I still have to compile my app with PB 5.24 LTS, because in all later versions some bugs prevent me from using this compiler. No problem so far, but now people complain that my app is crashing on High Sierra.

I tried to reproduce and yes, after a while i get a crash. Using lldb showing this:

2017-12-04 14:58:51.521659+0100 myApp[1411:20855] Month 13 is out of bounds
myApp(1411,0xa9a801c0) malloc: *** error for object 0x6cb0b0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Process 1411 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
frame #0: 0xa7642ef6 libsystem_kernel.dylib`__pthread_kill + 10
libsystem_kernel.dylib`__pthread_kill:
-> 0xa7642ef6 <+10>: jae 0xa7642f06 ; <+26>
0xa7642ef8 <+12>: calll 0xa7642efd ; <+17>
0xa7642efd <+17>: popl %edx
0xa7642efe <+18>: movl 0x242f12b(%edx), %edx
Target 0: (myApp) stopped.

After bt I get this stack:

* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
* frame #0: 0xa7642ef6 libsystem_kernel.dylib`__pthread_kill + 10
frame #1: 0xa77734d7 libsystem_pthread.dylib`pthread_kill + 363
frame #2: 0xa7592b2a libsystem_c.dylib`abort + 133
frame #3: 0xa769ceed libsystem_malloc.dylib`free + 513
frame #4: 0xa6a3f59e libobjc.A.dylib`_object_dispose(objc_object*) + 28
frame #5: 0x9134d657 AppKit`-[NSResponder dealloc] + 137
frame #6: 0x9134c2bc AppKit`-[NSView dealloc] + 162
frame #7: 0x91447f3a AppKit`-[NSControl dealloc] + 143
frame #8: 0x91625512 AppKit`-[NSTableView dealloc] + 932
frame #9: 0x001780f9 myApp`-[PB_NSTableView dealloc] + 89
frame #10: 0xa6a3a9f9 libobjc.A.dylib`objc_object::sidetable_release(bool) + 269
frame #11: 0xa6a382d0 libobjc.A.dylib`-[NSObject release] + 19
frame #12: 0xa6a378fc libobjc.A.dylib`(anonymous namespace)::AutoreleasePoolPage::pop(void*) + 698
frame #13: 0x938c2b98 CoreFoundation`_CFAutoreleasePoolPop + 24
frame #14: 0x952d5cc1 Foundation`-[NSAutoreleasePool release] + 120
frame #15: 0x001634c5 myApp`PB_Cocoa_FlushAutoreleasePool + 37
frame #16: 0x00164d31 myApp`PB_WaitWindowEvent2 + 129
frame #17: 0x00065a46 myApp`Repeat7383 + 10
Looks like it crashes in some function PB_WaitWindowEvent2 by freeing a pointer that is not allocated (any more?).

What can I do to make it run again? Interestingly, it does not crash in the IDE of PB 5.24 LTS on the same Mac. Only the compiled executable, compiled on El Capitan, seems affected :-( It worked fine on all previous Updates, but with 10.13 it starts to crash.

Any idea?
Last edited by Kukulkan on Mon Dec 04, 2017 5:06 pm, edited 1 time in total.
User avatar
Kukulkan
Addict
Addict
Posts: 1352
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Re: My app crashes under High Sierra

Post by Kukulkan »

After a long debug session I can say it crashes in WaitWindowEvent() function:

Code: Select all

...
Repeat
      GlobalLog(#RF_LOG_VERB, "A")
      ev = WaitWindowEvent(1) ; <--- CRASH HERE
      If ev <> 0
        GlobalLog(#RF_LOG_VERB, "B")
        handleWindowEvent(ev)
      EndIf
...
Last debug output I get is "A". My GlobalLog() function logs to a file.

Is this a known issue?

If compiled with PB 5.24 LTS on El Capitan, it crashes. If compiled with PB 5.24 LTS on High Sierra, it seem to work. Any idea about, how this can be?
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: My app crashes under High Sierra in WaitWindowEvent()

Post by mk-soft »

Mac with TouchBar?

Terminal:
defaults write -app "/Applications/YourAPP.app" NSFunctionBarAPIEnabled -bool NO
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Kukulkan
Addict
Addict
Posts: 1352
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Re: My app crashes under High Sierra in WaitWindowEvent()

Post by Kukulkan »

Mac with TouchBar?
Terminal:
defaults write -app "/Applications/YourAPP.app" NSFunctionBarAPIEnabled -bool NO
Sadly, it does not help. The value is set to 0, but no change (I tested using defaults read -app "/Applications/YourAPP.app").

Hm. Due to some forum search I think it was a PB bug that was somehow fixed by Fred in newer versions.

http://www.purebasic.fr/english/viewtopic.php?t=68404
http://www.purebasic.fr/english/viewtopic.php?t=66610

But I can't switch to a new PB compiler that fast. I run automatic builds, having a few hundred customers and a new PB compiler potentially having new bugs -> causing a new and long QA cycle for me.

Is it known, what function or usage the segfault caused? Maybe I can avoid that?
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: My app crashes under High Sierra in WaitWindowEvent()

Post by wilbert »

Kukulkan wrote:Is it known, what function or usage the segfault caused? Maybe I can avoid that?
It's hard to tell. Crashes during WaitWindowEvent have happened before. They can be caused by an object that was marked for autorelease and also manually released.

Are you using any date functions ?
I noticed the "Month 13 is out of bounds" like there's an array of 12 months and you are trying to access a 13th one.
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
Kukulkan
Addict
Addict
Posts: 1352
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Re: My app crashes under High Sierra in WaitWindowEvent()

Post by Kukulkan »

Hi,
It's hard to tell. Crashes during WaitWindowEvent have happened before. They can be caused by an object that was marked for autorelease and also manually released.
Okay, but how can I solve it? The program is really big and the same code worked fine since MacOS 10.7 to 10.12. Now, on 10.13 I get this annoying error. Not sure how to fix it :(

It looks like it works if it is compiled on Mac 10.13 (same compiler!). But that means that something from MacOS El Capitan is contained in my executable that crashes on High Sierra. But if I compile on High Sierra, I first have to check if it still works on El Capitan...
Are you using any date functions ?
I noticed the "Month 13 is out of bounds" like there's an array of 12 months and you are trying to access a 13th one.
It is a Mac bug: https://robservatory.com/month-13-is-out-of-bounds/
Post Reply