EimaMei / Silicon

An alternative, purely C-focused wrapper to Apple's Cocoa API for OS X app development and basic iOS programming. Requires little to no Objective-C knowledge to use.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Apple M2 + Sonoma: Save-file example crashes.

g40 opened this issue · comments

Hello.

save-file example crashes running under lldb after compiling with clang. lldb trace shown below.

Any thoughts?


Current executable set to '/Users/jevans/src/osx/Silicon-h/save-file' (arm64).
(lldb) r
Process 17950 launched: '/Users/jevans/src/osx/Silicon-h/save-file' (arm64)
2023-11-27 16:44:58.359539+0000 save-file[17950:2642947] [General] -[NSWindow OnButtonClick]: unrecognized selector sent to instance 0x129709fb0
2023-11-27 16:44:58.362152+0000 save-file[17950:2642947] [General] (
	0   CoreFoundation                      0x000000018ddce800 __exceptionPreprocess + 176
	1   libobjc.A.dylib                     0x000000018d8c5eb4 objc_exception_throw + 60
	2   CoreFoundation                      0x000000018de803bc -[NSObject(NSObject) __retain_OA] + 0
	3   CoreFoundation                      0x000000018dd38a84 ___forwarding___ + 1572
	4   CoreFoundation                      0x000000018dd383a0 _CF_forwarding_prep_0 + 96
	5   AppKit                              0x00000001916d8464 -[NSApplication(NSResponder) sendAction:to:from:] + 460
	6   AppKit                              0x00000001916d8268 -[NSControl sendAction:to:] + 72
	7   AppKit                              0x00000001916d81ac __26-[NSCell _sendActionFrom:]_block_invoke + 100
	8   AppKit                              0x00000001916d80d4 -[NSCell _sendActionFrom:] + 204
	9   AppKit                              0x00000001916d7ff8 -[NSButtonCell _sendActionFrom:] + 88
	10  AppKit                              0x00000001916d5628 NSControlTrackMouse + 1480
	11  AppKit                              0x00000001916d5034 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 144
	12  AppKit                              0x00000001916d4eec -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 488
	13  AppKit                              0x00000001916d43c0 -[NSControl mouseDown:] + 448
	14  AppKit                              0x00000001916d318c -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 3472
	15  AppKit                              0x000000019165e690 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 364
	16  AppKit                              0x000000019165e350 -[NSWindow(NSEventRouting) sendEvent:] + 284
	17  AppKit                              0x0000000191d07f30 -[NSApplication(NSEventRouting) sendEvent:] + 1604
	18  AppKit                              0x000000019195a110 -[NSApplication _handleEvent:] + 60
	19  AppKit                              0x0000000191526124 -[NSApplication run] + 512
	20  save-file                           0x000000010000197c NSApplication_run + 36
	21  save-file                           0x0000000100001330 main + 676
	22  dyld                                0x000000018d9010e0 start + 2360
)


Hey, is this a problem with silicon.h? If so it might be better to put the issue in that repository instead. I don't think Eima minds however.

I'll look into the issue later.

The crash seems to be caused by the ARM processor. However, even when running the program using x86 it outputs

2023-11-27 17:02:24.327 save-file[1430:17137] -[NSWindow OnButtonClick]: unrecognized selector sent to instance 0x7f940ad0bb50

Meaning the same issue is happening, just on ARM it results in a crash. This should be relatively easy to fix.

@ColleagueRiley Hello,

I'd agree re ARM64. Quite possibly related to the last problem.

BTW I am commenting here because issues are unavailable on your fork.

Oh, that's strange. Github acts a little strange when it comes to forks.

But the issue should be solved now.
It was more so an issue on my part and how I misinterpreted some code for the original example.

Well, one thing at a time.

It might be a good idea to add "-g -o0" to the clang command line in the meantime so debug info is maintained.

In respect of the latter:

Current executable set to '/Users/jevans/src/osx/Silicon-h/save-file' (arm64).
(lldb) r
Process 18887 launched: '/Users/jevans/src/osx/Silicon-h/save-file' (arm64)
2023-11-27 23:06:50.194143+0000 save-file[18887:2762430] [General] *** +[NSSavePanel<0x1e3e61dc8> init]: cannot init a class object.
2023-11-27 23:06:50.197646+0000 save-file[18887:2762430] [General] (
	0   CoreFoundation                      0x000000018ddce800 __exceptionPreprocess + 176
	1   libobjc.A.dylib                     0x000000018d8c5eb4 objc_exception_throw + 60
	2   CoreFoundation                      0x000000018de80690 +[NSObject(NSObject) dealloc] + 0
	3   save-file                           0x0000000100000aa8 NSInit + 36
	4   save-file                           0x000000010000095c OnButtonClick + 48
	5   AppKit                              0x00000001916d8464 -[NSApplication(NSResponder) sendAction:to:from:] + 460
	6   AppKit                              0x00000001916d8268 -[NSControl sendAction:to:] + 72
	7   AppKit                              0x00000001916d81ac __26-[NSCell _sendActionFrom:]_block_invoke + 100
	8   AppKit                              0x00000001916d80d4 -[NSCell _sendActionFrom:] + 204
	9   AppKit                              0x00000001916d7ff8 -[NSButtonCell _sendActionFrom:] + 88
	10  AppKit                              0x00000001916d5628 NSControlTrackMouse + 1480
	11  AppKit                              0x00000001916d5034 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 144
	12  AppKit                              0x00000001916d4eec -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 488
	13  AppKit                              0x00000001916d43c0 -[NSControl mouseDown:] + 448
	14  AppKit                              0x00000001916d318c -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 3472
	15  AppKit                              0x000000019165e690 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 364
	16  AppKit                              0x000000019165e350 -[NSWindow(NSEventRouting) sendEvent:] + 284
	17  AppKit                              0x0000000191d07f30 -[NSApplication(NSEventRouting) sendEvent:] + 1604
	18  AppKit                              0x000000019195a110 -[NSApplication _handleEvent:] + 60
	19  AppKit                              0x0000000191526124 -[NSApplication run] + 512
	20  save-file                           0x000000010000188c NSApplication_run + 36
	21  save-file                           0x0000000100001108 main + 688
	22  dyld                                0x000000018d9010e0 start + 2360
)

Is that output after the update? Is it still not working for you?

I do believe so.

I do believe so.

Well, the first issue was solved. But this actually helps a lot because I was just doing some testing and realized the function randomly stopped working running NSInit() (and returning to main on it's own)

So this actually shows that NSInit has some sort of error. That's weird that the x84 version doesn't even care to tell you that there was an issue and just leaves you to guess.

Okay, so it turned out there were two issues (with the last issue that you hadn't gotten two yet)

  1. a missing replacement function
  2. I messed something up when fixing the casting issue

Point being, both those issues are fixed now and the example should work as intended.

Excellent. The save-file example= works. I'll let you know if any other problems emerge. Thanks.