Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Attempt at fixing the crash in EventQueue destructor (lib) #4050

Closed

Conversation

MartinBriza
Copy link
Contributor

@MartinBriza MartinBriza commented May 5, 2020

This could fix the crash.

The rationale behind this is checking if the thread is valid. If it is, we need to determine if the destructor was called from the main thread or not.

I definitely don't recommend calling it from the EventQueue thread though, using the main thread to destroy everything seems to be the right call.

@NghiaTranUIT NghiaTranUIT self-requested a review May 6, 2020 07:27
Copy link
Contributor

@NghiaTranUIT NghiaTranUIT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The app is not crash but , unfortunately, the app is hanging when quitting the app

Steps to reproduce

  1. Start TogglDesktop on macOS
  2. Hit CMD+Q
  3. The app hangs in EventQueue's destructor

Screen Shot 2020-05-06 at 14 27 36

* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
    frame #0: 0x00007fff6984355e libsystem_kernel.dylib`__ulock_wait + 10
    frame #1: 0x000000010127411e libsystem_pthread.dylib`_pthread_join + 347
    frame #2: 0x00007fff66a0b5e6 libc++.1.dylib`std::__1::thread::join() + 24
  * frame #3: 0x0000000100c983d8 TogglDesktopLibrary.dylib`toggl::EventQueue::~EventQueue(this=0x000000010484b620) at eventqueue.cpp:18:24
    frame #4: 0x0000000100c98645 TogglDesktopLibrary.dylib`toggl::EventQueue::~EventQueue(this=0x000000010484b620) at eventqueue.cpp:11:27
    frame #5: 0x0000000100c1838e TogglDesktopLibrary.dylib`toggl::Context::~Context(this=0x000000010484b600) at context.cc:176:1
    frame #6: 0x0000000100c18bf5 TogglDesktopLibrary.dylib`toggl::Context::~Context(this=0x000000010484b600) at context.cc:133:21
    frame #7: 0x0000000100c18c1c TogglDesktopLibrary.dylib`toggl::Context::~Context(this=0x000000010484b600) at context.cc:133:21
    frame #8: 0x0000000100d05870 TogglDesktopLibrary.dylib`::toggl_context_clear(context=0x000000010484b600) at toggl_api.cc:54:5
    frame #9: 0x000000010002b0f3 TogglDesktop`-[AppDelegate applicationWillTerminate:](self=0x0000600003b08700, _cmd="applicationWillTerminate:", app=@"NSApplicationWillTerminateNotification") at AppDelegate.m:1125:2
    frame #10: 0x00007fff2f7af9cf CoreFoundation`__CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
    frame #11: 0x00007fff2f7af963 CoreFoundation`___CFXRegistrationPost1_block_invoke + 63
    frame #12: 0x00007fff2f7af8d8 CoreFoundation`_CFXRegistrationPost1 + 372
    frame #13: 0x00007fff2f7af544 CoreFoundation`___CFXNotificationPost_block_invoke + 80
    frame #14: 0x00007fff2f77f6bd CoreFoundation`-[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1554
    frame #15: 0x00007fff2f77eb69 CoreFoundation`_CFXNotificationPost + 1351
    frame #16: 0x00007fff31df5866 Foundation`-[NSNotificationCenter postNotificationName:object:userInfo:] + 59
    frame #17: 0x00007fff2cd04c38 AppKit`-[NSApplication terminate:] + 1385
    frame #18: 0x00007fff2cc79437 AppKit`-[NSApplication(NSResponder) sendAction:to:from:] + 299
    frame #19: 0x00007fff2cd89aee AppKit`-[NSMenuItem _corePerformAction] + 312
    frame #20: 0x00007fff2cd8986a AppKit`-[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 106
    frame #21: 0x00007fff2cd88767 AppKit`-[NSMenu performKeyEquivalent:] + 412
    frame #22: 0x00007fff2d1be27b AppKit`routeKeyEquivalent + 521
    frame #23: 0x00007fff2cbda4dd AppKit`-[NSApplication(NSEvent) sendEvent:] + 1161
    frame #24: 0x00007fff2ca2721f AppKit`-[NSApplication run] + 707
    frame #25: 0x00007fff2c9f8ff6 AppKit`NSApplicationMain + 777
    frame #26: 0x00000001000208e2 TogglDesktop`main(argc=3, argv=0x00007ffeefbff498) at main.m:13:9
    frame #27: 0x00007fff69700cc9 libdyld.dylib`start + 1
    frame #28: 0x00007fff69700cc9 libdyld.dylib`start + 1

@skel35
Copy link
Contributor

skel35 commented May 14, 2020

not relevant anymore as another solution was chosen

@skel35 skel35 closed this May 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants