Skip to contentSkip to conversation

linux-user: Remove stale "not threadsafe" comments

PATCH In review Peter Maydell 1 participant 2 messages Jan 14, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user: Remove stale "not threadsafe" comments

In linux-user/signal.c we have two FIXME comments claiming that parts of the signal-handling code are not threadsafe. These are very old, as they were first introduced in commit 624f7979058 in 2008. Since then we've radically overhauled the signal-handling logic, while carefully preserving these FIXME comments.

It's unclear exactly what thread-safety issue the original author was trying to point out -- the relevant data structures are in the TaskStruct, which makes them per-thread and only operated on by that thread. The old code at the time of that commit did have various races involving signal handlers being invoked at awkward times; possibly this was what was meant.

Delete these FIXME comments:
* they were written at a time when the way we handled signals was completely different
* the code today appears to us to not have thread-safety issues
* nobody knows what the problem the comments were trying to point out was
so they are serving no useful purpose for us today.

---
Marked "RFC" because I'm a bit uneasy with deleting FIXMEs simply because I can't personally figure out why they're there. This patch is more to start a discussion to see if anybody does understand the issue -- in which case we can instead augment the comments to describe it.

---
 linux-user/signal.c | 2 --
 1 file changed, 2 deletions(-)
linux-user/signal.c +0 -2
index 32854bb3752..e7410776e21 100644
@@ -1001,7 +1001,6 @@ int do_sigaction(int sig, const struct target_sigaction *act,
         oact->sa_mask = k->sa_mask;
     }
     if (act) {
-        /* FIXME: This is not threadsafe.  */
         __get_user(k->_sa_handler, &act->_sa_handler);
         __get_user(k->sa_flags, &act->sa_flags);
 #ifdef TARGET_ARCH_HAS_SA_RESTORER
@@ -1151,7 +1150,6 @@ void process_pending_signals(CPUArchState *cpu_env)
     sigset_t *blocked_set;
 
     while (qatomic_read(&ts->signal_pending)) {
-        /* FIXME: This is not threadsafe.  */
         sigfillset(&set);
         sigprocmask(SIG_SETMASK, &set, 0);
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 6 lines · Peter Maydell

In linux-user/signal.c we have two FIXME comments claiming that parts of the signal-handling code are not threadsafe. These are very old, as they were first introduced in commit 624f7979058 in 2008. Since then we've radically overhauled the signal-handling logic, while carefully preserving these FIXME comments.

Oops, I meant to send this as RFC, not PATCH -- I hit ^C on the send but obviously not quite in time to stop it getting out of the door. Ignore this one, I've sent it again with the right tag.

thanks
-- PMM