Closed fstanchina closed 2 years ago
Hey @fstanchina, it looks like you're fixing the same problem that https://github.com/MadLittleMods/node-usb-detection/pull/138 is trying to address.
And similar to the patch that @kfazz mentioned here https://github.com/MadLittleMods/node-usb-detection/issues/57#issuecomment-877195606
I'm going to close this in favor of those. But an updated PR welcome with the review feedback addressed is welcome!
OK, I agree. Sorry, I read thru the existing issues too fast.
The usb-detection native module causes a segfault in
udev_monitor_receive_device()
at exit on Linux arm64. It appears thatcbWork()
gets called with an invalid monitor object, I guess that on shutdown it's released before the worker stops.This could explain some sporadic crashes we've seen on Intel. Probably the less powerful hardware causes a race that is rarer on faster machines.
Here's a patch that fixes it, set
mon
to NULL after releasing (plus some diagnostics). I've actually seen the "Error: udev monitor is null in cbWork()!" message. Probably best would be to doauto tmp = mon; mon = NULL; udev_monitor_unref(tmp);
to guarantee that the worker never sees an invalidmon
.