Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: App crashes during load on some Macs



Permlink Replies: 3 - Last Post: Sep 8, 2017 3:16 AM Last Post By: Hans Jakobsen
Hans Jakobsen

Posts: 103
Registered: 9/10/01
App crashes during load on some Macs
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 28, 2017 11:30 AM
We just sent a new version of our application into beta test. Unfortunately two testers have reported that it crashes when they run the app.
We have tested the app with several different Mac computers (Mac mini, Macbook Pro and Macbook Air) using different versions of OS X, but have not seen any crash problems. Also all other beta testers have reported that it runs fine.

Looking at the crash reports (see below), I have no idea what causes the problems. It obviously tries to write to a read-only memory location, which indicates a pointer error.
* Is it related to code that I wrote? - or is it a general Delphi problem that happens only on certain configurations?
* Is there a fixed image base on Mac so I can lookup the addresses in a MAP file?

Any ideas how to proceed?

PS. I use Delphi Berlin Update 2

****************************** REPORT FROM USER 1 ******************************

OS Version: Mac OS X 10.11.6 (15G1611)
Model: MacBookPro11,1, Intel Core i5, 2.6 GHz, 8 GB,

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000000bf7ffdec
Exception Note: EXC_CORPSE_NOTIFY

VM Regions Near 0xbf7ffdec:
Stack 00000000b072f000-00000000b07b0000 [ 516K] rw-/rwx SM=COW
--> Stack Guard 00000000bc000000-00000000bf800000 [ 56.0M] ---/rwx SM=NUL
Stack 00000000bf800000-00000000c0000000 [ 8192K] rw-/rwx SM=PRV

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 com.apple.AppKit 0x96f2f03e _NSMapAndFilter + 12
1 com.apple.AppKit 0x96f3f702 -[NSApplication _copyVisibleFullScreenInstances] + 64
2 com.apple.AppKit 0x96f3f580 -[NSApplication _visibleFullScreenInstanceOnScreen:] + 59
3 com.apple.AppKit 0x96f3f4f4 -[NSScreen _menuBarHeight] + 97
4 com.apple.AppKit 0x96f3f45f -[NSScreen _layoutFrame] + 80
5 com.apple.AppKit 0x96f401df -[NSScreen visibleFrame] + 47
6 com.apple.AppKit 0x97068c57 _NSMakeWindowVisible + 315
7 com.apple.AppKit 0x97068b11 _NXMakeWindowVisible + 78
8 com.apple.AppKit 0x97068846 -[NSWindow constrainFrameRect:toScreen:] + 184
9 com.apple.AppKit 0x970822a9 -[NSWindow _overrideDefeatingConstrainFrameRect:toScreen:] + 1219
10 com.apple.AppKit 0x9700b484 -[NSWindow _oldPlaceWindow:] + 166
11 com.apple.AppKit 0x9700abde -[NSWindow _setFrameCommon:display:stashSize:] + 2929
12 com.apple.AppKit 0x9700a064 -[NSWindow _setFrame:display:allowImplicitAnimation:stashSize:] + 217
13 com.apple.AppKit 0x97009f86 -[NSWindow setFrame:display:] + 79
14 com.earmaster.ear70p 0x00173509 TMethodImplementationIntercept + 928685
15 com.earmaster.ear70p 0x004f8cb5 TMethodImplementationIntercept + 4621145
16 com.earmaster.ear70p 0x0058ecf4 TMethodImplementationIntercept + 5235608
17 com.earmaster.ear70p 0x0059215a TMethodImplementationIntercept + 5249022
18 com.earmaster.ear70p 0x005929ab TMethodImplementationIntercept + 5251151
19 com.earmaster.ear70p 0x004f5178 TMethodImplementationIntercept + 4605980
20 com.earmaster.ear70p 0x004f6af3 TMethodImplementationIntercept + 4612503
21 com.earmaster.ear70p 0x001730fe TMethodImplementationIntercept + 927650
22 com.apple.Foundation 0x99f7b512 __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_2 + 50
23 com.apple.CoreFoundation 0x95313e14 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
24 com.apple.CoreFoundation 0x95313d9b ___CFXRegistrationPost_block_invoke + 75
25 com.apple.CoreFoundation 0x95313d0c _CFXRegistrationPost + 460
26 com.apple.CoreFoundation 0x95313a46 ___CFXNotificationPost_block_invoke + 54
27 com.apple.CoreFoundation 0x952cd393 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1715
28 com.apple.CoreFoundation 0x952cc5b2 _CFXNotificationPost + 626
29 com.apple.Foundation 0x99f2d624 -[NSNotificationCenter postNotificationName:object:userInfo:] + 92
30 com.apple.Foundation 0x99f3bb20 -[NSNotificationCenter postNotificationName:object:] + 56
31 com.apple.AppKit 0x9700ac89 -[NSWindow _setFrameCommon:display:stashSize:] + 3100
32 com.apple.AppKit 0x9700a064 -[NSWindow _setFrame:display:allowImplicitAnimation:stashSize:] + 217
33 com.apple.AppKit 0x97009f86 -[NSWindow setFrame:display:] + 79
34 com.earmaster.ear70p 0x00173509 TMethodImplementationIntercept + 928685

... (and 500 more lines that just repeat the same sections, notice that line 34 is identical to line 14

****************************** REPORT FROM USER 2 ******************************

OS Version: Mac OS X 10.12.6 (16G29)

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000000bf7ffa2c
Exception Note: EXC_CORPSE_NOTIFY

Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [0]

VM Regions Near 0xbf7ffa2c:
Stack 00000000b0cc8000-00000000b0d49000 [ 516K] rw-/rwx SM=COW
--> Stack Guard 00000000bc000000-00000000bf800000 [ 56.0M] ---/rwx SM=NUL
Stack 00000000bf800000-00000000c0000000 [ 8192K] rw-/rwx SM=COW

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 com.apple.CoreFoundation 0x9421c9ec CFDictionaryCreateMutableCopy + 12
1 com.apple.CoreFoundation 0x94281e30 -[_CFXNotificationObjectRegistration find:matching:] + 272
2 com.apple.CoreFoundation 0x94276cf7 -[_CFXNotificationNameRegistration find:observer:matching:] + 231
3 com.apple.CoreFoundation 0x942353aa -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1498
4 com.apple.CoreFoundation 0x942342ad _CFXNotificationPost + 637
5 com.apple.Foundation 0x959f7b84 -[NSNotificationCenter postNotificationName:object:userInfo:] + 71
6 com.apple.Foundation 0x95a03ed8 -[NSNotificationCenter postNotificationName:object:] + 37
7 com.apple.AppKit 0x927ffc51 _NSWindowSendWindowDidMove + 57
8 com.apple.AppKit 0x9204b782 -[NSWindow _setFrameCommon:display:stashSize:] + 2676
9 com.apple.AppKit 0x9204ad05 -[NSWindow _setFrame:display:allowImplicitAnimation:stashSize:] + 217
10 com.apple.AppKit 0x9204ac26 -[NSWindow setFrame:display:] + 74
11 com.earmaster.ear70p 0x00173509 TMethodImplementationIntercept + 928685
... (same list of repetitions here)

Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: App crashes during load on some Macs
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 28, 2017 4:19 PM   in response to: Hans Jakobsen in response to: Hans Jakobsen
Hans Jakobsen wrote:

* Is it related to code that I wrote? -

The error is indicative of there being an observer to notifications that has been destroyed, but not removed from the
NSNotificationCenter. For OSX, I can see only one place where the call is made, which is in TFMXView.Create, in
FMX.Platform.Mac, and given the callstack you provided, it seems the likely candidate. There is a removeObserver call
in TFMXView.Destroy, which corresponds to the addObserver call in TFMXView.Create, so I don't quite know why the error
would be happening. Someone else might be able to chime in.

--
Dave Nottage [MVP, TeamB]
Find hints, tips and tricks at Delphi Worlds blog: http://www.delphiworlds.com
Hans Jakobsen

Posts: 103
Registered: 9/10/01
Re: App crashes during load on some Macs
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 29, 2017 12:19 AM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
The error is indicative of there being an observer to notifications that has been destroyed, but not removed from the
NSNotificationCenter.

Thanks for writing back :-) I have not implemented any use of NSNotificationCenter yet, so it must be something general in Delphi.
I also looked into TFMXView.Create, but it looks like you refer to the Tokyo edition. In Berlin there are no use of observers or NSNotificationCenter in TFMXView.Create. I searched all Berlin source code and did not find any Mac related use of NotificationCenter (only on iOS). Strange...

Since the app works on most computers, there must be a certain configuration of a Mac that causes this crash.
Hans Jakobsen

Posts: 103
Registered: 9/10/01
Re: App crashes during load on some Macs
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 8, 2017 3:16 AM   in response to: Hans Jakobsen in response to: Hans Jakobsen
I managed to identify what the problem was:
The MainForm had an OnResize that enforced a minimum Form Height at 750 pixels. Since the smallest screen of a Macbook is 800 pixels high, that worked fine on most Macs. However if the Dock had a certain size, the WorkAreaHeight of the screen was <750 pixels. OS X then tried to enforce a maximum height <750 pixels, while my app enforced a min height of 750 pixels. This caused an infinite loop in some situations.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02