Segmentation fault: 11Crash on MacBookPro, OK on iMac

I'm testing my OSX app developed with XCode Version 7.3.1 (7D1014) in Swift, in 2 environments :

- on iMac (Retina 5K - 24GB), OSX 10.11.6 (15G1217)

- on MacBookPro (15" - 16 GB) MacOS 10.12.3 (16D32)

I run in both cases from the Finder (not from within XCode).


On MBP I have a crash that I do not get on iMac ; it happens when I print some data (either select "show document in PDF in Preview" in the print dialog popup menu or print to a printer) However, the document shows correctly in Preview and print correctly.


On iMac, no crash ; If I run from within XCode with debugger, no crash either.


I followed Apple advice to performe a safe boot : https : / / discussions.apple.com/thread/3734077?start=0 => no change.

I had no printer installed. I installed One => no change.

I checke disk with S.O.S Disk utility : no issue detected.


Where should I look first ? Could this come from MacOS 10.12 change, with less permissive behavior ?


-----------------------------------------------


Here is the beginning crash report that shows

Process: MyApp [4884]

Path: /Users/USER/Desktop/MyApp V0.8c0.app/Contents/MacOS/MyApp

Identifier: XXXXXXX

Version: 0.8c0 (1)

Code Type: X86-64 (Native)

Parent Process: ??? [1]

Responsible: MyApp [4884]

User ID: 501


Date/Time: 2017-03-04 18:50:45.044 +0100

OS Version: Mac OS X 10.12.3 (16D32)

Report Version: 12

Anonymous UUID: XXXXXXXXX


Sleep/Wake UUID: XXXXXXXXXXX


Time Awake Since Boot: 27000 seconds

Time Since Wake: 33 seconds


System Integrity Protection: enabled


Crashed Thread: 0 Dispatch queue: com.apple.main-thread


Exception Type: EXC_BAD_ACCESS (SIGSEGV)

Exception Codes: KERN_INVALID_ADDRESS at 0x000007f810fc8978

Exception Note: EXC_CORPSE_NOTIFY


Termination Signal: Segmentation fault: 11

Termination Reason: Namespace SIGNAL, Code 0xb

Terminating Process: exc handler [0]


VM Regions Near 0x7f810fc8978:

MALLOC_LARGE 000000010f257000-000000010f557000 [ 3072K] rw-/rwx SM=PRV

-->

MALLOC_NANO 0000600000000000-0000600001400000 [ 20.0M] rw-/rwx SM=PRV


Thread 0 Crashed:: Dispatch queue: com.apple.main-thread

0 libobjc.A.dylib 0x00007fffa0500f6f objc_release + 31

1 libobjc.A.dylib 0x00007fffa0501e8d (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 781

2 com.apple.CoreFoundation 0x00007fff8b857856 _CFAutoreleasePoolPop + 22

3 com.apple.Foundation 0x00007fff8d2a1f13 -[NSAutoreleasePool drain] + 146

4 com.apple.AppKit 0x00007fff893befdc -[NSApplication run] + 1093

5 com.apple.AppKit 0x00007fff89389850 NSApplicationMain + 1237

6 (com.me.myApp) 0x0000000101c81644 main + 84

7 libdyld.dylib 0x00007fffa0df0255 start + 1

Answered by Claude31 in 214457022

Found the cause in my code : I leave this question on the forum as it may help others ; what I saw is that MacOS 10.12 is less permissive than 10.11 :


I had an NSTextView that was not used in some cases of print ;

it was declared as

theTextView : NSTextView


and it was initialized only if used ;

theTextView= NSTextView(frame: someRect)


I added an initialization in any cases at declaration :


theTextView : NSTextView = NSTextView(frame: CGRectZero)


Problem has disappeared ; was probably due to some deinit at the end of printing, where the property was not initialized. But question then : why did it work with 10.11 ?

---------------------


Another situation that shows less permissivenes : in a nib I had aligned the center of a button on the table view, instead of aligning on the middle of the parent scroll view ; it workd well in 10.11, but constraint was ignored in 10.12.

---------------------


Is there a way to know about those changes of behavior from 10.11 to 10.12 ?

Accepted Answer

Found the cause in my code : I leave this question on the forum as it may help others ; what I saw is that MacOS 10.12 is less permissive than 10.11 :


I had an NSTextView that was not used in some cases of print ;

it was declared as

theTextView : NSTextView


and it was initialized only if used ;

theTextView= NSTextView(frame: someRect)


I added an initialization in any cases at declaration :


theTextView : NSTextView = NSTextView(frame: CGRectZero)


Problem has disappeared ; was probably due to some deinit at the end of printing, where the property was not initialized. But question then : why did it work with 10.11 ?

---------------------


Another situation that shows less permissivenes : in a nib I had aligned the center of a button on the table view, instead of aligning on the middle of the parent scroll view ; it workd well in 10.11, but constraint was ignored in 10.12.

---------------------


Is there a way to know about those changes of behavior from 10.11 to 10.12 ?

Segmentation fault: 11Crash on MacBookPro, OK on iMac
 
 
Q