-
Notifications
You must be signed in to change notification settings - Fork 474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
utils: Add helpers for runtime dynamic patching #1705
base: master
Are you sure you want to change the base?
utils: Add helpers for runtime dynamic patching #1705
Conversation
3aff835
to
b748861
Compare
continue; | ||
} | ||
|
||
if (!oldact.sa_handler) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also this can be racy if other thread installs a new sighandler at the same time. But there's not much we can do..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, and furthermore, there is no guarantee that we're going to keep this signal to ourselves even if we don't get into a race condition here. The application can change our signal's disposition at any other point without notice. However, this function is only triggered upon dynamic runtime patching and unpatching via (do_dynamic_update) which we expect to be 1) infrequent 2) not happening at any particular time, e.g., application startup. Hence, the likelihood of this condition is low.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, then we need to take care of releasing the rt signal after use.
Glibc < 2.30 doen't provide wrappers for 'gettid()' and 'tgkill()' so we define them. Signed-off-by: Clément Guidi <[email protected]>
Functions to setup real-time signals and broadcast signals to all threads in an application. Useful for runtime synchronization mechanisms. Co-authored-by: Gabriel-Andrew Pollo-Guilbert <[email protected]> Signed-off-by: Clément Guidi <[email protected]>
b748861
to
0398ceb
Compare
if (errno != ESRCH) { | ||
pr_dbg2("cannot signal thread %u: %s\n", task, strerror(errno)); | ||
errno = 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems we should not take ESRCH
as an error. Something like this?
if (tgkill(pid, task, sig) < 0) {
if (errno != ESRCH)
pr_dbg2(...);
errno = 0;
}
continue; | ||
} | ||
|
||
if (!oldact.sa_handler) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, then we need to take care of releasing the rt signal after use.
This is the fourth PR in a series of patches intended to bring runtime dynamic tracing on x86_64 to uftrace.
We add syscall wrappers and signal-related functions that will be useful for runtime dynamic instrumentation.
Related: #1698