fix(preload): apps that reload libudev no longer crash in the input wrappers (#3180)

fix(preload): keep libudev loaded while the input wrappers use it

Programs that close libudev and open it again crashed in the next wrapped
udev call: the wrappers kept function pointers into the unmapped copy.
Pin libudev with RTLD_NODELETE when it is opened so those pointers and
the stored handle stay valid.
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-24 20:19:53 -05:00
1 parent 906e66e3cf
commit 238ef76c5c
3 files changed
+45 -5

No files matched your search

+5 -3
View File
@@ -419,9 +419,11 @@ static void *real_dlsym(void);
* searches, so the handle the program opened is the only way back to the real implementation. */
static _Atomic(void *) udev_handle;
__attribute__((visibility("hidden"))) void bl_inputudev_note_dlopen(const char *path, void *handle) {
if (handle != NULL && path != NULL && strstr(path, "libudev") != NULL)
atomic_store_explicit(&udev_handle, handle, memory_order_release);
__attribute__((visibility("hidden"))) void bl_inputudev_note_dlopen(const char *path, void *handle,
void *(*open)(const char *, int)) {
if (handle == NULL || path == NULL || strstr(path, "libudev") == NULL) return;
if (open(path, RTLD_LAZY | RTLD_NOLOAD | RTLD_NODELETE) == NULL) return;
atomic_store_explicit(&udev_handle, handle, memory_order_release);
}
static void *next_symbol(const char *name) {