hammerspoon: Hammerspoon crash caused by calling hs.serial.deviceCallback() and reloading
I am finding that my Hammerspoon crashes whenever I try to use the hs.serial.deviceCallback function. Indeed, I was able to replicate the crash on two separate Macs (both M1 Mac minis), by simply using an init.lua file with the following contents:
hs.serial.deviceCallback(function(devices)
end)
After loading that init.lua, Hammerspoon launches OK, but then the next time Hammerspoon is reloaded, it crashes.
It’s possible that it’s an M1 issue; I’ll try it on my Intel Mac at home when I get a chance. If there’s any other information needed to debug, I’ll do my best to get it.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (16 by maintainers)
Commits related to this issue
- Fix crash in hs.serial.deviceCallback(). Closes #3118 — committed to Hammerspoon/hammerspoon by cmsj 2 years ago
Thanks so much guys, sorry I wasn’t able to contribute much! Love Hammerspoon, and love the developers!
attached PR fixes the crash at least. I’m not sure I have any serial port devices to test it with though!
The line in question is:
but that line doesn’t make a lot of sense, because it can be called right after
watcherDeviceManageris created, at which pointdeviceCallbackRefwould beLUA_NOREFwhich is a fatal error if passed toluaUnref::.I also note that
watcherDeviceManageris not stopped/deallocated inmeta_gc, which means that across reloads its state is inconsistent because it may retain Lua references that no longer exist, and itsgcCanarywill be stale.