Crash wenn Quit

Meine App crashed, wenn ich sie beende. Allerdings nicht im Debugger, nur wenn sie compiliert ist (OSX, 64 bit, Xojo 2016R4.1)

Um das zu verhindern, habe ich im CancelClose Event der App folgenden Code (siehe unten)
Da das Daten sichern evtl. viel Zeit benötigt wegen db.commit, bei großer db, starte ich einen Timer der auf 2000 steht, um nach dem Sichern das Quit durchzuführen. Das Problem ist nur, der wird nicht ausgeführt, der Timer startet einfach nicht… mache ich hier einen Denkfehler?
Hat jemand einen besseren Anstaz für diese Problematik?

Danke

if must_save then Hauptfenster.daten_sichern sicherepref_xml Hauptfenster.timer_quit.mode=1 return true end if

Zeige uns doch mal den relevanten Teil des Crash-Reports.

Wo genau crasht denn Dein Programm? Wie startest Du den Timer?

Was meinst du denn mit “Wie startest du den Timer?” ?? oben im Code…

Hier der Report:

VM Regions Near 0x8:
–>
__TEXT 0000000104daa000-00000001054eb000 [ 7428K] r-x/rwx SM=COW /Applications/Dev/*/Sammler - Mineralien.app/Contents/MacOS/Sammler - Mineralien

Application Specific Information:
Performing @selector(menuItemAction:) from sender NSMenuItem 0x7fa008f31bb0

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 com.xojo.XojoFramework 0x00000001059ab9b2 RuntimeObjectIsa + 83
1 com.xojo.XojoFramework 0x00000001059bd70f RuntimeViewDestructor + 142
2 de.onlymac.minerals 0x0000000104db406c Window.__Exit%%o + 12
3 com.xojo.XojoFramework 0x00000001059ab7e4 RuntimeUnlockObject + 792
4 com.xojo.XojoFramework 0x00000001058cd108 0x105808000 + 807176
5 com.xojo.XojoFramework 0x00000001058bf5d2 0x105808000 + 751058
6 com.xojo.XojoFramework 0x00000001059fce77 0x105808000 + 2051703
7 com.xojo.XojoFramework 0x00000001058bf476 0x105808000 + 750710
8 com.xojo.XojoFramework 0x00000001058bf62d 0x105808000 + 751149
9 com.xojo.XojoFramework 0x00000001059ddd7c QuitMenuAction + 46
10 de.onlymac.minerals 0x0000000104dd69f7 QuitMenuItem.Event_Action%b%o + 55
11 com.xojo.XojoFramework 0x0000000105917279 0x105808000 + 1110649
12 com.xojo.XojoFramework 0x000000010582ddb8 0x105808000 + 155064
13 libsystem_trace.dylib 0x00007fff87b6e07a _os_activity_initiate + 75
14 com.apple.AppKit 0x00007fff860bcdbd -[NSApplication sendAction:to:from:] + 460
15 com.apple.AppKit 0x00007fff860bcb57 -[NSMenuItem _corePerformAction] + 336
16 com.apple.AppKit 0x00007fff860bc8b7 -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 114
17 libsystem_trace.dylib 0x00007fff87b6e07a _os_activity_initiate + 75
18 com.apple.AppKit 0x00007fff860bb7a5 -[NSMenu performKeyEquivalent:] + 357
19 com.apple.AppKit 0x00007fff860ba949 -[NSApplication _handleKeyEquivalent:] + 920
20 com.apple.AppKit 0x00007fff85fe10fe -[NSApplication sendEvent:] + 4274
21 com.xojo.XojoFramework 0x000000010584664c 0x105808000 + 255564
22 de.onlymac.minerals 0x0000000104f0c717 Delegate.Invoke%% + 7
23 de.onlymac.minerals 0x0000000104e099c1 Application._CallFunctionWithExceptionHandling%%op + 273
24 com.xojo.XojoFramework 0x00000001059a9beb 0x105808000 + 1711083
25 com.xojo.XojoFramework 0x00000001058465c6 0x105808000 + 255430
26 com.apple.AppKit 0x00007fff85e47df2 -[NSApplication run] + 796
27 com.xojo.XojoFramework 0x00000001059a7fbb RuntimeRun + 40
28 de.onlymac.minerals 0x0000000104eddd68 REALbasic._RuntimeRun + 24
29 de.onlymac.minerals 0x000000010540d26a _Main + 538
30 de.onlymac.minerals 0x0000000105407901 main + 65
31 de.onlymac.minerals 0x0000000104dab7d4 start + 52

Thread 1:
0 libsystem_kernel.dylib 0x00007fff9a5055e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff895d2578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff895d0341 start_wqthread + 13

Thread 2:: Dispatch queue: com.apple.libdispatch-manager
0 libsystem_kernel.dylib 0x00007fff9a505efa kevent_qos + 10
1 libdispatch.dylib 0x00007fff895f9165 _dispatch_mgr_invoke + 216
2 libdispatch.dylib 0x00007fff895f8dcd _dispatch_mgr_thread + 52

Thread 3:
0 libsystem_kernel.dylib 0x00007fff9a5055e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff895d2578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff895d0341 start_wqthread + 13

Thread 4:
0 libsystem_kernel.dylib 0x00007fff9a5055e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff895d2578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff895d0341 start_wqthread + 13

Thread 5:
0 libsystem_kernel.dylib 0x00007fff9a5055e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff895d2578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff895d0341 start_wqthread + 13

Thread 6:
0 libsystem_kernel.dylib 0x00007fff9a5055e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff895d2578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff895d0341 start_wqthread + 13

Thread 7:

Thread 8:: com.apple.NSEventThread
0 libsystem_kernel.dylib 0x00007fff9a4fef72 mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff9a4fe3b3 mach_msg + 55
2 com.apple.CoreFoundation 0x00007fff891d5124 __CFRunLoopServiceMachPort + 212
3 com.apple.CoreFoundation 0x00007fff891d45ec __CFRunLoopRun + 1356
4 com.apple.CoreFoundation 0x00007fff891d3e38 CFRunLoopRunSpecific + 296
5 com.apple.AppKit 0x00007fff85fa9d95 _NSEventThread + 149
6 libsystem_pthread.dylib 0x00007fff895d299d _pthread_body + 131
7 libsystem_pthread.dylib 0x00007fff895d291a _pthread_start + 168
8 libsystem_pthread.dylib 0x00007fff895d0351 thread_start + 13

Thread 9:
0 libsystem_kernel.dylib 0x00007fff9a50510a __semwait_signal + 10
1 libsystem_c.dylib 0x00007fff8c7e6d0f nanosleep + 199
2 libc++.1.dylib 0x00007fff95c92020 std::__1::this_thread::sleep_for(std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&) + 75
3 com.apple.JavaScriptCore 0x00007fff95b4187b bmalloc::Heap::scavenge(std::__1::unique_lockbmalloc::StaticMutex&, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000l> >) + 155
4 com.apple.JavaScriptCore 0x00007fff95b414d4 bmalloc::Heap::concurrentScavenge() + 68
5 com.apple.JavaScriptCore 0x00007fff95b43a5a bmalloc::AsyncTask<bmalloc::Heap, void (bmalloc::Heap::)()>::entryPoint() + 90
6 com.apple.JavaScriptCore 0x00007fff95b439f9 bmalloc::AsyncTask<bmalloc::Heap, void (bmalloc::Heap::
)()>::pthreadEntryPoint(void*) + 9
7 libsystem_pthread.dylib 0x00007fff895d299d _pthread_body + 131
8 libsystem_pthread.dylib 0x00007fff895d291a _pthread_start + 168
9 libsystem_pthread.dylib 0x00007fff895d0351 thread_start + 13

Thread 10:: JavaScriptCore::Marking
0 libsystem_kernel.dylib 0x00007fff9a504db6 __psynch_cvwait + 10
1 libsystem_pthread.dylib 0x00007fff895d3728 _pthread_cond_wait + 767
2 libc++.1.dylib 0x00007fff95c5368f std::__1::condition_variable::wait(std::__1::unique_lockstd::__1::mutex&) + 47
3 com.apple.JavaScriptCore 0x00007fff9551842b JSC::GCThread::waitForNextPhase() + 171
4 com.apple.JavaScriptCore 0x00007fff95518278 JSC::GCThread::gcThreadMain() + 88
5 com.apple.JavaScriptCore 0x00007fff9550dbf2 WTF::threadEntryPoint(void*) + 178
6 com.apple.JavaScriptCore 0x00007fff9550db1f WTF::wtfThreadEntryPoint(void*) + 15
7 libsystem_pthread.dylib 0x00007fff895d299d _pthread_body + 131
8 libsystem_pthread.dylib 0x00007fff895d291a _pthread_start + 168
9 libsystem_pthread.dylib 0x00007fff895d0351 thread_start + 13

Thread 11:: JavaScriptCore::Marking
0 libsystem_kernel.dylib 0x00007fff9a504db6 __psynch_cvwait + 10
1 libsystem_pthread.dylib 0x00007fff895d3728 _pthread_cond_wait + 767
2 libc++.1.dylib 0x00007fff95c5368f std::__1::condition_variable::wait(std::__1::unique_lockstd::__1::mutex&) + 47
3 com.apple.JavaScriptCore 0x00007fff9551842b JSC::GCThread::waitForNextPhase() + 171
4 com.apple.JavaScriptCore 0x00007fff95518278 JSC::GCThread::gcThreadMain() + 88
5 com.apple.JavaScriptCore 0x00007fff9550dbf2 WTF::threadEntryPoint(void*) + 178
6 com.apple.JavaScriptCore 0x00007fff9550db1f WTF::wtfThreadEntryPoint(void*) + 15
7 libsystem_pthread.dylib 0x00007fff895d299d _pthread_body + 131
8 libsystem_pthread.dylib 0x00007fff895d291a _pthread_start + 168
9 libsystem_pthread.dylib 0x00007fff895d0351 thread_start + 13

Thread 12:: JavaScriptCore::Marking
0 libsystem_kernel.dylib 0x00007fff9a504db6 __psynch_cvwait + 10
1 libsystem_pthread.dylib 0x00007fff895d3728 _pthread_cond_wait + 767
2 libc++.1.dylib 0x00007fff95c5368f std::__1::condition_variable::wait(std::__1::unique_lockstd::__1::mutex&) + 47
3 com.apple.JavaScriptCore 0x00007fff9551842b JSC::GCThread::waitForNextPhase() + 171
4 com.apple.JavaScriptCore 0x00007fff95518278 JSC::GCThread::gcThreadMain() + 88
5 com.apple.JavaScriptCore 0x00007fff9550dbf2 WTF::threadEntryPoint(void*) + 178
6 com.apple.JavaScriptCore 0x00007fff9550db1f WTF::wtfThreadEntryPoint(void*) + 15
7 libsystem_pthread.dylib 0x00007fff895d299d _pthread_body + 131
8 libsystem_pthread.dylib 0x00007fff895d291a _pthread_start + 168
9 libsystem_pthread.dylib 0x00007fff895d0351 thread_start + 13

Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x00007fa009009200 rcx: 0x0000000000001400 rdx: 0x0000000000000000
rdi: 0x00007fa00b00e880 rsi: 0x00007fa009009201 rbp: 0x00007fff5ae54f50 rsp: 0x00007fff5ae54f40
r8: 0x0000000000000007 r9: 0x00000000fff00000 r10: 0x0000000105bc3201 r11: 0x00000001059bd681
r12: 0x0000000105bb67e8 r13: 0x00007fa008eb2160 r14: 0x00007fa00b00e880 r15: 0x00007fa00b060bb0
rip: 0x00000001059ab9b2 rfl: 0x0000000000010287 cr2: 0x000000010bbd1000

Logical CPU: 0
Error Code: 0x02000131
Trap Number: 133

Sorry, die Zeile mit dem Timer habe ich übersehen.

Das Quit-Menuitem crasht da. Wahrscheinlich zwischen dem Aufruf und dem Start des Timers. Ich würde mal einen Bug von Xojo vermuten. Hast Du schon die aller-neuste Version als Pre-Release-Tester ausprobiert?

Was passiert, wenn Du den Timer einfach wegläßt? Das Sichern kann ja so lange dauern, wie es will im Cancel-Close.

Nein, die allerneuste lade ich gerade…

Das Problem ist, der Timer wird nie gestartet… wie kann das denn sein?

OK, es scheint ein 64bit Problem in 2016R4.1 zu sein, bei 32bit tritt es nicht auf.
Mit der allerneusten Pre-release probiere ich es in ca. 100 Jahren,wenn alle Plugins neu compiliert sind (-;

Der Crash passiert wohl zwischen Cancel-Close und dem Starten des Timers. Aber ich vermute, da Du den Timer gar nicht brauchst.

Abgesehen vom Timer Problem, ‘Return True’ in ‘CancelClose’ verhindert doch das Beenden des Programms?

Ja, genau, deshalb starte ich ja vorher einen Timer, der dann das Programm beendet… wenn eben die Daten gesichert sind.
Sollte gar nicht nötig sein, aber ich wollte halt einen Weg finden den Crash zu umgehen.

Mit der allerneuste Pre-release crahsed es immer noch… aber auch nicht im Debugger mit 64bit nur in den compilierten App.

Ich will morgen die App veröffnetlichen… bleibt mir nur 32bit!

Ich hatte mal ein hnliches Problem (allerdings in Linux), das ein Programm nach Speichern und Quit trotzdem nicht beendet wurde.
Vielleicht geht es so.

if not appQuitting then Quit
if must_save then
Hauptfenster.daten_sichern
sicherepref_xml
return false
end if

Im Debugger ist alles gut, egal in welcher Variante, aber in der compilierten App geht es dann schief.
Bei 32bit OHNE Crash, bei 64bit MIT Crash, aber gesichert werden die Daten in beiden Fllen nicht, das ist doch verrckt!

das könnte ja bedeuten das must_save False ist ?

Man könnte es meinen, aber im Debugger geht es ja… (und ich habs nochmal überprüft) das muss ein Bug mit CancelClose sein, anders kann ich es mir nicht erklären.

<https://xojo.com/issue/47023>