Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: QSProcessMonitor crashes Quicksilver #3008

Open
3 tasks done
n8henrie opened this issue May 15, 2024 · 12 comments
Open
3 tasks done

[Bug]: QSProcessMonitor crashes Quicksilver #3008

n8henrie opened this issue May 15, 2024 · 12 comments

Comments

@n8henrie
Copy link
Member

Before submitting your bug report, please confirm you have completed the following steps

Bug description

As per the title -- we have a number of crashes in QSProcessMonitor. This will be a meta-issue with links to a few relevant issues.

For example, I get a EXC_BAD_ACCESS at

return [data objectForKey:aKey];

My

Steps to reproduce

  1. Start QS
  2. Enable Running Applications & Processes in Settings -> Catalog -> Applications
  3. Wait a few minutes to hours

Expected behavior

No crash

MacOS Version

Other

Quicksilver Version

2.4.2

Relevant Plugins

No response

Crash Logs or Spindump

The callstack during a crash:

#1	0x0000000184f77d90 in -[__NSDictionaryM objectForKey:] ()
#2	0x0000000105efa56c in -[QSObject _safeObjectForType:] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSObject.m:416
#3	0x0000000105efa610 in -[QSObject objectForType:] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSObject.m:429
#4	0x0000000105f2a6a0 in __54-[QSProcessMonitor processObjectWithPSN:fromSnapshot:]_block_invoke at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSProcessMonitor.m:207
#5	0x0000000184f98904 in __NSDICTIONARY_IS_CALLING_OUT_TO_A_BLOCK__ ()
#6	0x0000000184fbe2f0 in __NSDictionaryEnumerate ()
#7	0x0000000105f2a538 in -[QSProcessMonitor processObjectWithPSN:fromSnapshot:] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSProcessMonitor.m:206
#8	0x0000000105f2a33c in -[QSProcessMonitor processObjectWithPSN:] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSProcessMonitor.m:195
#9	0x0000000105f2b240 in -[QSProcessMonitor appTerminated:] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSProcessMonitor.m:313
#10	0x0000000105f29be4 in __appTerminated_block_invoke at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSProcessMonitor.m:103

Screenshots

No response

Additional info

No response

@n8henrie
Copy link
Member Author

Seem to have just had a crash at

NSBundle *bundle = [NSBundle bundleWithIdentifier:ident];
, but XCode said it was "paused" -- unclear if I fat fingered something while it was running in the background.

@n8henrie
Copy link
Member Author

For users thinking that this might be the cause of their crashes, consider disabling QSProcessMonitor in your settings by going to: Preferences -> Catalog -> Applications and unchecking Running Applications & Processes

@n8henrie
Copy link
Member Author

n8henrie commented Jun 3, 2024

Hi all,

I made a few related changes in the process-monitor-crashes branch, and it seems to be running much more stably for me.

If anyone would be willing to try out a debug version with these changes, I'd appreciate the feedback, I'll probably merge and cut a new release in a week or so if things seem improved:

EDIT:

NB: This is a pre-release version that is not signed, so you'll have to do a little dance to get MacOS to allow you to open the application; it usually involves multiple rounds of right-clicking (or two-finger tapping) the application and choosing "open" followed by a dialog warning you about it being from an "unidentified developer": https://support.apple.com/guide/mac-help/open-a-mac-app-from-an-unidentified-developer-mh40616/mac

@n8henrie
Copy link
Member Author

n8henrie commented Jun 7, 2024

Looks like the same crash is still occurring: #2990 (comment)

@n8henrie
Copy link
Member Author

I'm still occasionally getting some of these EXC_BAD_ACCESS crashes coming through QSProcessMonitor, in spite of converting things to use the threadsafedictionary. Would appreciate any input from @pjrobertson @skurfer or anyone more familiar with ObjC.

Just now, crash is at

return [cache objectForKey:aKey];

#0	0x000000019cee9c08 in objc_msgSend ()
#1	0x00000001032f7fb4 in -[QSThreadSafeMutableDictionary objectForKey:] ()
#2	0x00000001033c2d9c in -[QSObject objectForCache:] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSObject.m:461
#3	0x00000001033cdac8 in -[QSObject(FileHandling) fileExtension] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSObject_FileHandling.m:831
#4	0x00000001033cd73c in -[QSObject(FileHandling) isClipping] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSObject_FileHandling.m:810
#5	0x00000001033cbf8c in +[QSObject(FileHandling) fileObjectWithPath:] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSObject_FileHandling.m:631
#6	0x00000001033f243c in -[QSProcessMonitor imbuedFileProcessForDict:] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSProcessMonitor.m:179
#7	0x00000001033f3f20 in -[QSProcessMonitor reloadProcesses] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSProcessMonitor.m:391
#8	0x00000001033f326c in -[QSProcessMonitor appLaunched:] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSProcessMonitor.m:298
#9	0x00000001033f1d44 in __appLaunched_block_invoke at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSProcessMonitor.m:82
#10	0x0000000102cdcf2c in _dispatch_call_block_and_release ()
#11	0x0000000102cdeba4 in _dispatch_client_callout ()
#12	0x0000000102ce7d88 in _dispatch_lane_serial_drain ()
#13	0x0000000102ce8e7c in _dispatch_lane_invoke ()
#14	0x0000000102cf8958 in _dispatch_root_queue_drain_deferred_wlh ()
#15	0x0000000102cf7c30 in _dispatch_workloop_worker_thread ()
#16	0x000000010359bd40 in _pthread_wqthread ()

AFAICT cache should be thread safe.

@n8henrie n8henrie pinned this issue Jul 9, 2024
@n8henrie
Copy link
Member Author

n8henrie commented Jul 9, 2024

Well, I probably should have discovered Xcode's Address Sanitizer and Thread Sanitizer sooner. I still need to figure out how to use them and my superficial familiarity with ObjC is not helping, but it seems like it's a step in the right direction.

Thread Sanitizer identifies data races right where I've been getting crashes in QSThreadSafeMutableDictionary:

/Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepFoundation/QSThreadSafeMutableDictionary.m:107 Data race in -[QSThreadSafeMutableDictionary objectForKey:] at 0x10a08c920

Location is a 16-byte heap object at 0x10a08c920
Read of size 8 by thread 17
#0	0x0000000106c9be10 in -[QSThreadSafeMutableDictionary objectForKey:] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepFoundation/QSThreadSafeMutableDictionary.m:107
#1	0x0000000106f56b70 in -[QSObject objectForCache:] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSObject.m:461
#2	0x0000000106f6990c in -[QSObject(FileHandling) fileExtension] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSObject_FileHandling.m:831
#3	0x0000000106f69390 in -[QSObject(FileHandling) isClipping] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSObject_FileHandling.m:810
#4	0x0000000106f66b20 in +[QSObject(FileHandling) fileObjectWithPath:] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSObject_FileHandling.m:631
#5	0x0000000106fa46bc in -[QSProcessMonitor imbuedFileProcessForDict:] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSProcessMonitor.m:179
#6	0x0000000106fa753c in -[QSProcessMonitor reloadProcesses] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSProcessMonitor.m:391
#7	0x0000000106fa5f00 in -[QSProcessMonitor appLaunched:] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSProcessMonitor.m:298
#8	0x0000000106fa3ac4 in __appLaunched_block_invoke at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSProcessMonitor.m:82
#9	0x00000001051a82e8 in __tsan::invoke_and_release_block(void*) ()
#10	0x00000001070aaba4 in _dispatch_client_callout ()
Write of size 8 by thread 21
#0	0x0000000106c9b260 in -[QSThreadSafeMutableDictionary initWithCapacity:] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepFoundation/QSThreadSafeMutableDictionary.m:58
#1	0x000000018ba6cbd0 in -[NSMutableDictionary initWithObjects:forKeys:count:] ()
#2	0x0000000106f546c0 in -[QSObject copyWithZone:] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSObject.m:293
#3	0x0000000106f47c54 in -[QSLibrarian typeArraysFromArray:] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSLibrarian.m:527
#4	0x0000000106f46c88 in -[QSLibrarian recalculateTypeArraysForItem:] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSLibrarian.m:463
#5	0x0000000106f45014 in -[QSLibrarian reloadSets:] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSLibrarian.m:337
#6	0x000000018b98b144 in __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ ()
#7	0x0000000106f28a10 in -[QSCatalogEntry scanForced:] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSCatalogEntry.m:719
#8	0x0000000106f43d9c in __28-[QSLibrarian reloadSource:]_block_invoke at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSLibrarian.m:273
#9	0x00000001051a82e8 in __tsan::invoke_and_release_block(void*) ()
#10	0x00000001070aaba4 in _dispatch_client_callout ()
Heap block allocated by thread 21
#0	0x000000010517e2d0 in wrap_calloc ()
#1	0x000000018b4e5d84 in _objc_rootAllocWithZone ()
#2	0x0000000106f546c0 in -[QSObject copyWithZone:] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSObject.m:293
#3	0x0000000106f47c54 in -[QSLibrarian typeArraysFromArray:] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSLibrarian.m:527
#4	0x0000000106f46c88 in -[QSLibrarian recalculateTypeArraysForItem:] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSLibrarian.m:463
#5	0x0000000106f45014 in -[QSLibrarian reloadSets:] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSLibrarian.m:337
#6	0x000000018b98b144 in __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ ()
#7	0x0000000106f28a10 in -[QSCatalogEntry scanForced:] at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSCatalogEntry.m:719
#8	0x0000000106f43d9c in __28-[QSLibrarian reloadSource:]_block_invoke at /Users/n8henrie/git/qs/quicksilver/Quicksilver/Code-QuickStepCore/QSLibrarian.m:273
#9	0x00000001051a82e8 in __tsan::invoke_and_release_block(void*) ()
#10	0x00000001070aaba4 in _dispatch_client_callout ()

@tangoTH
Copy link

tangoTH commented Sep 1, 2024

Adding my thread 2990 (before this one) here
#2990

Still crashing after debug images and updates.

I have disabled the Running Process catalog. Will revert back if/when the next crash occurs

@n8henrie
Copy link
Member Author

v2.4.3 has been released and contains some relevant fixes. Can subscribers to this thread please update and report back?

@mrstanwell
Copy link

I've upgraded. Thanks so much for your work, @n8henrie !

@terrazzano
Copy link

terrazzano commented Nov 28, 2024

Thanks @n8henrie for picking this up.

Random background crashes still persist.

For me started 2 days ago, for no clear reason, on a previous version. Updated to v2.4.3 still crashing, 15 times in 2 days. Meanwhile I installed v2.4.3:Debug (4042)

I'm running MacOS Monterey 12.7.1 on Macbook Air M1

Other things I observed while analyzing crash reports in Console.app

  • 5 out of 15 crash reports: "Time Since Wake: 1 seconds"
  • All crash reports fired round number of seconds from boot: "Time Awake Since Boot: 84000 seconds" - always at least two zeroes (***00)
  • Application Specific Information: abort() called

Attaching last crash report
Untitled.txt

Any other info I should deliver?

@mrstanwell
Copy link

FWIW, I'm on Sonoma (14.5), and QS 2.4.3 has been stable for me. My laptop's current uptime is 19 days, and QS hasn't crashed in that time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants