syscall handler mod: fix double-warn race condition#3338
syscall handler mod: fix double-warn race condition#3338sporksmith merged 1 commit intoshadow:mainfrom
Conversation
Detect when another thread has raced to warn about a missing syscall number before us, ensuring we really do only warn once about a particular missing syscall number. This doesn't seem like a substantial problem in practice, but looking at this code again it seems silly not to do this slightly better handling.
| // already-warned set. Also detect the (rare) case that another | ||
| // thread already warned after we released the read-lock above. | ||
| let has_already_warned = has_already_warned | ||
| || WARNED_SET |
There was a problem hiding this comment.
This seems backwards to me? insert should return true when it's added for the first time, which would mean has_already_warned should be false.
There was a problem hiding this comment.
Doh, right. Will follow up with another fix.
Whenever I look at this code I'm tempted to just use a Mutex instead of a RwLock since it shouldn't be on the hot path, but always end up deciding "oh well, this one last tweak should fix it once and for all anyway"
There was a problem hiding this comment.
Yeah it originally used a mutex, but then was changed to RwLock during review. As far as I remember there wasn't a strong argument for either one.
I did refactor this into a separate module as part of #3332, but I'm not sure if/when I'll merge that.
Detect when another thread has raced to warn about a missing syscall number before us, ensuring we really do only warn once about a particular missing syscall number.
This doesn't seem like a substantial problem in practice, but looking at this code again it seems silly not to do this slightly better handling.