Xcode App crashing when run outside of build environment

Hi All,


I am having trouble resolving this issue. My simple process monitor runs fine when run from the xcode environment where it was built. But attempting to run it from the Finder by double-clicking, or any other way leads it to crashing when I interact with the button on the GUI. This is the crash log.


I am having trouble discerning if this is a build setting issue, or a code issue. Please let me know of what path this may be, and of any advice. Thanks in advance


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


Process: SwiftProcessMonitor [69907]

Path: /Users/USER/Library/Developer/Xcode/DerivedData/SwiftProcessMonitor-cqkaoqiyibepbvardmcsgiwszdwz/Build/Products/Debug/SwiftProcessMonitor.app/Contents/MacOS/SwiftProcessMonitor

Identifier: pdas.SwiftProcessMonitor

Version: 1.0 (1)

Code Type: X86-64 (Native)

Parent Process: ??? [1]

Responsible: SwiftProcessMonitor [69907]

User ID: 501



Date/Time: 2020-05-19 18:29:50.709 -0400

OS Version: Mac OS X 10.15.4 (19E266)

Report Version: 12

Anonymous UUID: EE80D59F-82AB-354C-9B7C-3E2A6F16B8CE





Time Awake Since Boot: 620000 seconds



System Integrity Protection: disabled



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



Exception Type: EXC_BAD_ACCESS (SIGSEGV)

Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000

Exception Note: EXC_CORPSE_NOTIFY



Termination Signal: Segmentation fault: 11

Termination Reason: Namespace SIGNAL, Code 0xb

Terminating Process: exc handler [69907]



VM Regions Near 0:

-->

__TEXT 00000001020aa000-00000001020b4000 [ 40K] r-x/r-x SM=COW /Users/USER/Library/Developer/Xcode/DerivedData/SwiftProcessMonitor-cqkaoqiyibepbvardmcsgiwszdwz/Build/Products/Debug/SwiftProcessMonitor.app/Contents/MacOS/SwiftProcessMonitor



Application Specific Information:

Performing @selector(BeginMonitor:) from sender NSButton 0x7ffc95d13a30



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

0 libEndpointSecurity.dylib 0x00007fff6626d911 es_subscribe + 16

1 pdas.SwiftProcessMonitor 0x00000001020ac9f8 -[ProcessMonitor subscribe] + 88

2 pdas.SwiftProcessMonitor 0x00000001020af340 ViewController.BeginMonitor(_:) + 80 (ViewController.swift:44)

3 pdas.SwiftProcessMonitor 0x00000001020af3b0 @objc ViewController.BeginMonitor(_:) + 80

4 com.apple.AppKit 0x00007fff2cc9b437 -[NSApplication(NSResponder) sendAction:to:from:] + 299

5 com.apple.AppKit 0x00007fff2cc9b2d2 -[NSControl sendAction:to:] + 86

6 com.apple.AppKit 0x00007fff2cc9b204 __26-[NSCell _sendActionFrom:]_block_invoke + 136

7 com.apple.AppKit 0x00007fff2cc9b106 -[NSCell _sendActionFrom:] + 171

8 com.apple.AppKit 0x00007fff2cc9b04d -[NSButtonCell _sendActionFrom:] + 96

9 com.apple.AppKit 0x00007fff2cc9732b NSControlTrackMouse + 1745

10 com.apple.AppKit 0x00007fff2cc96c32 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 130

11 com.apple.AppKit 0x00007fff2cc96af1 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 691

12 com.apple.AppKit 0x00007fff2cc95e6d -[NSControl mouseDown:] + 748

13 com.apple.AppKit 0x00007fff2cc94280 -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 4914

14 com.apple.AppKit 0x00007fff2cbfea81 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 2612

15 com.apple.AppKit 0x00007fff2cbfde29 -[NSWindow(NSEventRouting) sendEvent:] + 349

16 com.apple.AppKit 0x00007fff2cbfc1b4 -[NSApplication(NSEvent) sendEvent:] + 352

17 com.apple.AppKit 0x00007fff2ca4921f -[NSApplication run] + 707

18 com.apple.AppKit 0x00007fff2ca1aff6 NSApplicationMain + 777

19 pdas.SwiftProcessMonitor 0x00000001020b199d main + 13 (AppDelegate.swift:12)

20 libdyld.dylib 0x00007fff697e7cc9 start + 1



Thread 1:

0 libsystem_pthread.dylib 0x00007fff699ebb68 start_wqthread + 0



Thread 2:

0 libsystem_pthread.dylib 0x00007fff699ebb68 start_wqthread + 0



Thread 3:

0 libsystem_pthread.dylib 0x00007fff699ebb68 start_wqthread + 0



Thread 4:

0 libsystem_pthread.dylib 0x00007fff699ebb68 start_wqthread + 0



Thread 5:

0 libsystem_pthread.dylib 0x00007fff699ebb68 start_wqthread + 0



Thread 6:

0 libsystem_pthread.dylib 0x00007fff699ebb68 start_wqthread + 0



Thread 7:

0 libsystem_pthread.dylib 0x00007fff699ebb68 start_wqthread + 0



Thread 8:

0 libsystem_pthread.dylib 0x00007fff699ebb68 start_wqthread + 0



Thread 9:: com.apple.NSEventThread

0 libsystem_kernel.dylib 0x00007fff69928dfa mach_msg_trap + 10

1 libsystem_kernel.dylib 0x00007fff69929170 mach_msg + 60

2 com.apple.CoreFoundation 0x00007fff2f7edbf7 __CFRunLoopServiceMachPort + 247

3 com.apple.CoreFoundation 0x00007fff2f7ec6b1 __CFRunLoopRun + 1329

4 com.apple.CoreFoundation 0x00007fff2f7ebb23 CFRunLoopRunSpecific + 466

5 com.apple.AppKit 0x00007fff2cbfa5b4 _NSEventThread + 132

6 libsystem_pthread.dylib 0x00007fff699f0109 _pthread_start + 148

7 libsystem_pthread.dylib 0x00007fff699ebb8b thread_start + 15



Thread 0 crashed with X86 Thread State (64-bit):

rax: 0xa0669916dde900b9 rbx: 0x000060000103a440 rcx: 0x0000000b00000009 rdx: 0x0000000000000003

rdi: 0x0000000000000000 rsi: 0x00007ffeedb54c2c rbp: 0x00007ffeedb54bf0 rsp: 0x00007ffeedb54bd0

r8: 0x00000000000000cb r9: 0x00000000000007fb r10: 0x00007ffeedb55be8 r11: 0x00007fff6626d901

r12: 0x000060000041c160 r13: 0x000060000041c160 r14: 0x0000000000000003 r15: 0x00007ffeedb54c2c

rip: 0x00007fff6626d911 rfl: 0x0000000000010202 cr2: 0x0000000000000000


Logical CPU: 4

Error Code: 0x00000004 (no mapping for user data read)

Trap Number: 14

Replies

I have tested with some Mac Apps, no problem, neither on Mojave nor more older OS.

So it is mots likely a problem in your code or your conf.


Which version of XCode ?

Does it crash only on MacOS 10.15.4 or did it crash with previous OS versions ?

How do you transfer the app to the Finder ?


crashing when I interact with the button on the GUI

- Does it crash before executing the button action ?

- if it crashes in the action, please post the code

- does it crash after completing the IBAction ?


Seems you try to access to invalid address at the beginning of ViewController.swift code.

Could you post this complete file ?