Skip to content

udev: prevent interruption by thread cancellation#153

Open
wuguanghao3 wants to merge 1 commit into
opensvc:masterfrom
wuguanghao3:master
Open

udev: prevent interruption by thread cancellation#153
wuguanghao3 wants to merge 1 commit into
opensvc:masterfrom
wuguanghao3:master

Conversation

@wuguanghao3

Copy link
Copy Markdown

Using mutexes only guarantees no concurrency during normal runtime. However, if a thread is cancelled mid-execution, a libudev API call might be interrupted halfway (partially executed), leaving memory values in an inconsistent or abnormal state.

Furthermore, this change aligns with the requirement that libudev interfaces are not thread-safe and must not be called from multiple threads.

fixed #152

Using mutexes only guarantees no concurrency during normal runtime.
However, if a thread is cancelled mid-execution, a libudev API call
might be interrupted halfway (partially executed), leaving memory
values in an inconsistent or abnormal state.

Furthermore, this change aligns with the requirement that libudev
interfaces are not thread-safe and must not be called from multiple
threads.

Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
@mwilck

mwilck commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Good catch! I would prefer to move the implementation into mt-libudev.c, though.

@mwilck mwilck left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't do direct merges into master, except for new releases. Please create a PR against the "queue" branch in github.com/openSUSE/multipath-tools, which is our staging area.

#define udev_ref(udev) mt_udev_ref(udev)
#define udev_unref(udev) mt_udev_unref(udev)
#define udev_new() mt_udev_new()
#define MT_NO_CANCEL(call) \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this into mt-libudev.c and use it as wrapper for the actual libudev calls?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

free(): invalid pointer

2 participants