ryanmcgrath / cacao

Rust bindings for AppKit (macOS) and UIKit (iOS/tvOS). Experimental, but working!
MIT License
1.85k stars 68 forks source link

todos_list Example Program Crashes in Release Mode #125

Open flymonkey00 opened 3 weeks ago

flymonkey00 commented 3 weeks ago

When compiling the todos_list example program in release mode, adding an item and then attempting to use a swipe gesture to trigger the complete action causes the program to crash. This crash is consistently reproducible in release mode but does not occur when compiled in debug mode.

Steps to Reproduce:

  1. Compile the todos_list example program in release mode.
  2. Add a new item to the list.
  3. Attempt to use a swipe gesture to mark the item as complete.

Expected Behavior:

The item should be marked as complete without any issues.

Actual Behavior:

The program crashes when the swipe gesture is used to mark an item as complete.

Crash Stack Trace:

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

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x000007f81f4c8878
Exception Note:        EXC_CORPSE_NOTIFY

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

VM Regions Near 0x7f81f4c8878:
    CoreAnimation               1149c6000-1149e6000    [  128K] rw-/rwx SM=PRV  
--> 
    STACK GUARD              70000bd06000-70000bd07000 [    4K] ---/rwx SM=NUL  stack guard for thread 1

Thread 0 Crashed:: main  Dispatch queue: com.apple.main-thread
0   libobjc.A.dylib                 0x00007fff20249997 lookUpImpOrForward + 61
1   libobjc.A.dylib                 0x00007fff2024939b _objc_msgSend_uncached + 75
2   com.apple.AppKit                0x00007fff236715b4 -[NSTableRowData _setupEditActionsButtonsForActions:edge:] + 366
3   com.apple.AppKit                0x00007fff23671f28 -[NSTableRowData _setSwipeToDeleteRow:editActions:edge:] + 525
4   com.apple.AppKit                0x00007fff236701bc -[NSTableRowData _startSwipeOnRow:withEvent:] + 204
5   com.apple.AppKit                0x00007fff2344c039 -[NSTableView _handleScrollWheelSwipeWithEvent:] + 136
6   com.apple.AppKit                0x00007fff2344c6ba -[NSTableView scrollWheel:] + 304
7   com.apple.AppKit                0x00007fff22ebedf8 forwardMethod + 204
8   com.apple.AppKit                0x00007fff22f91a8b -[NSView scrollWheel:] + 349
9   com.apple.AppKit                0x00007fff22ebedf8 forwardMethod + 204
10  com.apple.AppKit                0x00007fff22f91a8b -[NSView scrollWheel:] + 349
11  com.apple.AppKit                0x00007fff22ebedf8 forwardMethod + 204
12  com.apple.AppKit                0x00007fff22f91a8b -[NSView scrollWheel:] + 349
13  com.apple.AppKit                0x00007fff22e35eb8 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 6482
14  com.apple.AppKit                0x00007fff22e34346 -[NSWindow(NSEventRouting) sendEvent:] + 347
15  com.apple.AppKit                0x00007fff22e3300b -[NSApplication(NSEvent) sendEvent:] + 2583
16  com.apple.AppKit                0x00007fff2310b4f1 -[NSApplication _handleEvent:] + 65
17  com.apple.AppKit                0x00007fff22c9b5ee -[NSApplication run] + 623
18  todos_list                      0x0000000102560d99 0x102540000 + 134553
19  todos_list                      0x000000010256bc26 0x102540000 + 179238
20  todos_list                      0x000000010256bc3c 0x102540000 + 179260
21  todos_list                      0x00000001025b59c7 std::rt::lang_start_internal::h66ad601203e00d0b + 743
22  todos_list                      0x0000000102560dfc main + 44
23  libdyld.dylib                   0x00007fff203c5f3d start + 1
ryanmcgrath commented 3 weeks ago

This is likely the same (ish) issue as #122 - probably a thing that was being properly retained before is not being retained now.

I have to find time to dig in and poke at this stuff, but I've been fairly busy as of late - but the last non-beta version should theoretically be fine if you're finding this a blocker. Appreciate the heads up otherwise!

flymonkey00 commented 3 weeks ago

Thank you for your prompt response. However, I apologize as I'm not an iOS/macOS developer, so I may not be able to provide much help on more in-depth technical aspects. Perhaps after I gain a more detailed understanding of Objective-C's reference counting mechanism, I may be able to offer some ideas.

And yes, you're right, 0.4.0-beta2 works fine~