You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.
The usb-detection native module causes a segfault in udev_monitor_receive_device() at exit on Linux arm64. It appears that cbWork() 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 do auto tmp = mon; mon = NULL; udev_monitor_unref(tmp); to guarantee that the worker never sees an invalid mon.
diff -ur ../usb-detection_save/src/detection_linux.cpp node_modules/usb-detection/src/detection_linux.cpp--- ../usb-detection_save/src/detection_linux.cpp 2022-02-07 16:12:26.198991223 +0100+++ node_modules/usb-detection/src/detection_linux.cpp 2022-02-07 16:23:07.020071344 +0100@@ -98,7 +98,9 @@
uv_cond_destroy(¬ifyDeviceHandled);
udev_monitor_unref(mon);
+ mon = NULL;
udev_unref(udev);
+ udev = NULL;
}
void InitDetection() {
@@ -112,6 +114,12 @@
/* Set up a monitor to monitor devices */
mon = udev_monitor_new_from_netlink(udev, "udev");
+ if (!mon)+ {+ printf("Can't create udev monitor from netlink\n");+ return;+ }+
udev_monitor_enable_receiving(mon);
/* Get the file descriptor (fd) for the monitor.
@@ -226,6 +234,12 @@
if (!ret) continue;
if (ret < 0) break;
+ if (!mon)+ {+ printf("Error: udev monitor is null in cbWork()!\n");+ return;+ }+
dev = udev_monitor_receive_device(mon);
if (dev) {
if(udev_device_get_devtype(dev) && strcmp(udev_device_get_devtype(dev), DEVICE_TYPE_DEVICE) == 0) {
The text was updated successfully, but these errors were encountered:
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
.The text was updated successfully, but these errors were encountered: