swiftbar/SwiftBar

Segfault crashing every so often

NReilingh opened this issue · 27 comments

Describe the bug
I have SwiftBar set to open on login, but often when I look at my menubar it is missing and has to be restarted. I checked Console.app today and found a crash report, below. I only run one plugin, which is also included below.

To Reproduce
SwiftBar-2023-07-08-171947.ips.txt

Screenshots
If applicable, add screenshots to help explain your problem.

Environment:

  • macOS version: 13.4.1 Apple Silicon
  • SwiftBar version: 1.4.4

Plugin Example:
Plugin: inetest.1s.sh

if ping -c 1 -t 1 8.8.8.8 &>/dev/null; then
  echo "|sfimage=checkmark.icloud"
else
  echo "|sfimage=xmark.icloud.fill"
fi

Additional Context:

  • SwiftBar set to open on login. No other configuration to my recollection.

I'm having a similar issue on Intel / SwiftBar 1.4.4 with a similar exception error:

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

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x00004a0d06c34920
Exception Codes:       0x0000000000000001, 0x00004a0d06c34920

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [792]

Possibly useful additional info: I've recently changed the interval to 2s and I don't believe I have seen any further crashes since then. I'll see if that continues to hold true, but it seems at least the incidences have decreased.

I wonder if that implies a race condition somewhere, since usually the script will return faster than 1 second, but on the else branch, the script returns after waiting for a 1 second timeout from ping.

This is an interesting observation @NReilingh, thank you. I'll try to look into it and replicate.

huyz commented

I've been having crashes pretty regularly (on average maybe twice per day), as I mentioned at #376.

I seem to be getting all types of crashes (SIGABRT, SIGSEV, SIGBUS).

I run:

  • drselump14's "Show Time machine Progress" every 1m
  • my own script every 10s
  • another one of my scripts every 10m

I also run Bartender (mentioning in case the constant rearrangement of icons has something to do with crashing)

Process:               SwiftBar [60389]
Path:                  /Applications/SwiftBar.app/Contents/MacOS/SwiftBar
Identifier:            com.ameba.SwiftBar
Version:               1.4.4 (461)
Code Type:             ARM-64 (Native)
Parent Process:        launchd [1]
User ID:               501

Date/Time:             2023-08-06 00:21:18.8984 -0700
OS Version:            macOS 13.5 (22G74)
Report Version:        12
Anonymous UUID:        25736505-D900-4C30-9B4B-4DE7B97B7E0F

Sleep/Wake UUID:       75450D55-151C-4A15-A032-E11F24CD086D

Time Awake Since Boot: 75000 seconds
Time Since Wake:       58202 seconds

System Integrity Protection: enabled

Crashed Thread:        7  Dispatch queue: NSOperationQueue 0x153f1b500 (QOS: USER_INITIATED)

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000

Termination Reason:    Namespace SIGNAL, Code 6 Abort trap: 6
Terminating Process:   SwiftBar [60389]
Process:               SwiftBar [13222]
Path:                  /Applications/SwiftBar.app/Contents/MacOS/SwiftBar
Identifier:            com.ameba.SwiftBar
Version:               1.4.4 (461)
Code Type:             ARM-64 (Native)
Parent Process:        launchd [1]
User ID:               501

Date/Time:             2023-08-05 03:54:53.8500 -0700
OS Version:            macOS 13.5 (22G74)
Report Version:        12
Anonymous UUID:        25736505-D900-4C30-9B4B-4DE7B97B7E0F

Sleep/Wake UUID:       50B8A886-E154-4446-8F4A-7F93F0262CDF

Time Awake Since Boot: 9400 seconds
Time Since Wake:       38 seconds

System Integrity Protection: enabled

Crashed Thread:        7  Dispatch queue: NSOperationQueue 0x12a8566c0 (QOS: USER_INITIATED)

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000400000000
Exception Codes:       0x0000000000000001, 0x0000000400000000

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [13222]

Process:               SwiftBar [42592]
Path:                  /Applications/SwiftBar.app/Contents/MacOS/SwiftBar
Identifier:            com.ameba.SwiftBar
Version:               1.4.4 (461)
Code Type:             ARM-64 (Native)
Parent Process:        launchd [1]
User ID:               501

Date/Time:             2023-08-04 05:23:28.7473 -0700
OS Version:            macOS 13.5 (22G74)
Report Version:        12
Anonymous UUID:        25736505-D900-4C30-9B4B-4DE7B97B7E0F


Time Awake Since Boot: 67000 seconds

System Integrity Protection: enabled

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

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000020
Exception Codes:       0x0000000000000001, 0x0000000000000020

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [42592]

VM Region Info: 0x20 is not in any region.  Bytes before following region: 105553518919648
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      MALLOC_NANO (reserved)   600018000000-600020000000 [128.0M] rw-/rwx SM=NUL  ...(unallocated)
Process:               SwiftBar [1176]
Path:                  /Applications/SwiftBar.app/Contents/MacOS/SwiftBar
Identifier:            com.ameba.SwiftBar
Version:               1.4.4 (461)
Code Type:             ARM-64 (Native)
Parent Process:        launchd [1]
User ID:               501

Date/Time:             2023-07-31 04:26:56.1451 -0700
OS Version:            macOS 13.5 (22G74)
Report Version:        12
Anonymous UUID:        25736505-D900-4C30-9B4B-4DE7B97B7E0F


Time Awake Since Boot: 17000 seconds

System Integrity Protection: enabled

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

Exception Type:        EXC_BAD_ACCESS (SIGBUS)
Exception Codes:       KERN_PROTECTION_FAILURE at 0x0000000200000000
Exception Codes:       0x0000000000000002, 0x0000000200000000

Termination Reason:    Namespace SIGNAL, Code 10 Bus error: 10
Terminating Process:   exc handler [1176]

All, please try running this build, it includes crash reporting(through Microsoft AppCenter, please don't block access to it), this should help me debuggin the issue.

Thanks @melonamin, just started using the crash reporting build.

huyz commented

Interestingly, it has stopped crashing. Could it be that it was crashing because I was blocking Microsoft AppCenter before?

Could it be that it was crashing because I was block Microsoft AppCenter before?

Not likely, Crash Reporting is not enabled in the latest production verision. Most likely some of the other changes in this build(there are a lot of them) fixed the issue you were facing.

Anyway, keep me posted if you see any crashes, so far I don't see anything in the report.

huyz commented

Anyway, keep me posted if you see any crashes, so far I don't see anything in the report.

I'm confident my problems were fixed. My crashes were very consistent before this build, multiple times a day. Now I haven't had a single crash!

Thank you for all the great work.

@huyz That’s great to hear! I need to wrap up 2.0 and finally ship it…

@NReilingh how a bout your experience with this build?

@melonamin I just had a crash this morning and I'm using the debug/logging version. Let me know if you got a crashlog. It happened at 8:59am PST.

I'm getting multiple crashes a day on latest; is there a way I can help debug?

All, please try running this build, it includes crash reporting(through Microsoft AppCenter, please don't block access to it), this should help me debuggin the issue.

@beaugunderson If you run the build linked here ^ that should enable crashlog tracking

awesome; just switched to that--where will the crash logs show up?

Regardless of version they should (I think) show up in your local machine's console.app. But this version is to send crashlogs directly to the author.

Yeah, I don't see crash reports on my end for whatever reason 😭Looking into it.

Meanwhile @jakemauer is correct Console.app -> Crash Reports should contain it.

@melonamin is there a way I can force a crash, or is there a way for you to add a button or something in the special build that sends a test message to the crash reporter?

ah, I do see crash reports in Console.app; I sent one to gist in case that makes this easier :)

https://gist.github.com/beaugunderson/86e54b7040727fb1ba2c5edfdb736309

38871

here's an additional (SIGSEGV vs the first which was not): https://gist.github.com/beaugunderson/8b87490336d191c3a56b6d270b9897ee

huyz commented

My first crash in 16 days.

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               SwiftBar [32763]
Path:                  /Applications/SwiftBar.app/Contents/MacOS/SwiftBar
Identifier:            com.ameba.SwiftBar
Version:               2.0.0 (502)
Code Type:             ARM-64 (Native)
Parent Process:        launchd [1]
User ID:               501

Date/Time:             2023-08-21 15:08:26.7021 -0700
OS Version:            macOS 13.5.1 (22G90)
Report Version:        12
Anonymous UUID:        25736505-D900-4C30-9B4B-4DE7B97B7E0F

Sleep/Wake UUID:       EA5E964C-FA7A-4E43-B08E-FB671533C213

Time Awake Since Boot: 110000 seconds
Time Since Wake:       59882 seconds

System Integrity Protection: enabled

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

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000

Termination Reason:    Namespace SIGNAL, Code 6 Abort trap: 6
Terminating Process:   SwiftBar [32763]

@melonamin did you get that AppCenter cash report?

@huyz no, I didn't :(

I should have more time in the following weeks to look into this, sorry for slow progress.

@NReilingh how a bout your experience with this build?

@melonamin Hey, sorry for the delay -- I just got around to installing the crash-reporting build. I also set my plugin frequency back to 1s. I'm actually on a new mac now as well. Will see what happens from here on out and report back if I experience a crash.

I think I fixed the crash reporting, please try 2.0.0-beta-1

Check if Crash Reporting is enabled in settings:
Screenshot 2023-09-23 at 10 11 22

huyz commented

I've only had that one crash since. So all good anyway

Installed the new beta with the crash reports checkbox. I don't believe I experienced a crash in the interim, even with the frequency set back to 1s. So things have been going well, but I'll continue to keep an eye on it.

@melonamin Just installed the newest beta, I'll keep you posted. Thank you!

I've had two crashes today, the first a SIGSEGV and the second a SIGABRT.

The segfault crash:

Crashed Thread:        5  Dispatch queue: NSOperationQueue 0x13df0d4d0 (QOS: USER_INITIATED)

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x000000031ea1f550
Exception Codes:       0x0000000000000001, 0x000000031ea1f550

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [2543]

VM Region Info: 0x31ea1f550 is not in any region.  Bytes after previous region: 2203252049  Bytes before following region: 54246902448
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      mapped file                 290000000-29b4f0000    [180.9M] r--/rw- SM=COW  ...t_id=7d05abd9
--->  GAP OF 0xd24b10000 BYTES
      commpage (reserved)         fc0000000-1000000000   [  1.0G] ---/--- SM=NUL  ...(unallocated)

[...]

Thread 5 Crashed::  Dispatch queue: NSOperationQueue 0x13df0d4d0 (QOS: USER_INITIATED)
0   libsystem_malloc.dylib        	       0x18e43a9e8 tiny_free_no_lock + 1860
1   libsystem_malloc.dylib        	       0x18e43a120 free_tiny + 496
2   Foundation                    	       0x18f6163e4 -[NSConcreteData dealloc] + 96
3   libobjc.A.dylib               	       0x18e27fbd4 AutoreleasePoolPage::releaseUntil(objc_object**) + 196
4   libobjc.A.dylib               	       0x18e27c79c objc_autoreleasePoolPop + 256
5   Foundation                    	       0x18f64c620 -[NSOperation start] + 1144
6   Foundation                    	       0x18f64c1a0 __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ + 16
7   Foundation                    	       0x18f64c090 __NSOQSchedule_f + 172
8   libdispatch.dylib             	       0x18e462874 _dispatch_call_block_and_release + 32
9   libdispatch.dylib             	       0x18e464400 _dispatch_client_callout + 20
10  libdispatch.dylib             	       0x18e467884 _dispatch_continuation_pop + 504
11  libdispatch.dylib             	       0x18e466eec _dispatch_async_redirect_invoke + 584
12  libdispatch.dylib             	       0x18e475e98 _dispatch_root_queue_drain + 396
13  libdispatch.dylib             	       0x18e4766c0 _dispatch_worker_thread2 + 164
14  libsystem_pthread.dylib       	       0x18e610038 _pthread_wqthread + 228
15  libsystem_pthread.dylib       	       0x18e60ed94 start_wqthread + 8

The abort crash:

Crashed Thread:        8  Dispatch queue: NSOperationQueue 0x12e842e60 (QOS: USER_INITIATED)

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000

Termination Reason:    Namespace SIGNAL, Code 6 Abort trap: 6
Terminating Process:   SwiftBar [62261]

Application Specific Information:
abort() called

[...]

Thread 8 Crashed::  Dispatch queue: NSOperationQueue 0x12e842e60 (QOS: USER_INITIATED)
0   libsystem_kernel.dylib        	       0x18e5dc744 __pthread_kill + 8
1   libsystem_pthread.dylib       	       0x18e613c28 pthread_kill + 288
2   libsystem_c.dylib             	       0x18e521ae8 abort + 180
3   libswiftCore.dylib            	       0x19d6c7ad8 swift::fatalErrorv(unsigned int, char const*, char*) + 136
4   libswiftCore.dylib            	       0x19d6c7af8 swift::fatalError(unsigned int, char const*, ...) + 32
5   libswiftCore.dylib            	       0x19d6cc520 swift_deallocClassInstance + 180
6   libswiftCore.dylib            	       0x19d6cc388 _swift_release_dealloc + 56
7   libswiftCore.dylib            	       0x19d6cd108 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1>>::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 132
8   SwiftBar                      	       0x104f14218 0x104ed4000 + 262680
9   SwiftBar                      	       0x104f142c0 0x104ed4000 + 262848
10  Foundation                    	       0x18f64d054 __NSOPERATION_IS_INVOKING_MAIN__ + 16
11  Foundation                    	       0x18f64c46c -[NSOperation start] + 708
12  Foundation                    	       0x18f64c1a0 __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ + 16
13  Foundation                    	       0x18f64c090 __NSOQSchedule_f + 172
14  libdispatch.dylib             	       0x18e462874 _dispatch_call_block_and_release + 32
15  libdispatch.dylib             	       0x18e464400 _dispatch_client_callout + 20
16  libdispatch.dylib             	       0x18e467884 _dispatch_continuation_pop + 504
17  libdispatch.dylib             	       0x18e466eec _dispatch_async_redirect_invoke + 584
18  libdispatch.dylib             	       0x18e475e98 _dispatch_root_queue_drain + 396
19  libdispatch.dylib             	       0x18e4766c0 _dispatch_worker_thread2 + 164
20  libsystem_pthread.dylib       	       0x18e610038 _pthread_wqthread + 228
21  libsystem_pthread.dylib       	       0x18e60ed94 start_wqthread + 8

I had previously reported similar crashes as #319 but things had been pretty good until about two weeks ago. I'll install the beta release.