quicksilver / Quicksilver

Quicksilver Project Source
http://qsapp.com
Apache License 2.0
2.72k stars 283 forks source link

[Bug]: QSProcessMonitor crashes Quicksilver #3008

Open n8henrie opened 1 month ago

n8henrie commented 1 month ago

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 https://github.com/quicksilver/Quicksilver/blob/f4f679f3a9a0dc377214e150761ff633a9807a13/Quicksilver/Code-QuickStepCore/QSObject.m#L412

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 commented 1 month ago

Related issues:

n8henrie commented 1 month ago

Seem to have just had a crash at https://github.com/quicksilver/Quicksilver/blob/f4f679f3a9a0dc377214e150761ff633a9807a13/Quicksilver/Code-QuickStepCore/QSProcessMonitor.m#L170, but XCode said it was "paused" -- unclear if I fat fingered something while it was running in the background.

n8henrie commented 1 month ago

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 commented 1 month ago

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 commented 4 weeks ago

Looks like the same crash is still occurring: https://github.com/quicksilver/Quicksilver/issues/2990#issuecomment-2153738223

n8henrie commented 2 weeks ago

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 https://github.com/quicksilver/Quicksilver/blob/af772d58691fc54d9f41bdc1a7690c78dd0a6e3b/Quicksilver/Code-QuickStepCore/QSObject.m#L461

#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.