Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

utils/utils.c Outdated Show resolved Hide resolved
utils/utils.c Outdated Show resolved Hide resolved
continue;
}

if (!oldact.sa_handler)
Copy link
Owner

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..

Copy link

@azharivs azharivs Aug 1, 2023

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.

Copy link
Owner

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.

clementguidi and others added 2 commits July 26, 2023 11:53
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]>
@clementguidi clementguidi force-pushed the utils-runtime-dynamic-patching branch from b748861 to 0398ceb Compare July 26, 2023 15:54
if (errno != ESRCH) {
pr_dbg2("cannot signal thread %u: %s\n", task, strerror(errno));
errno = 0;
}
Copy link
Owner

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)
Copy link
Owner

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.

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.

3 participants