You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
os/signal: notify should filter out runtime-generated SIGURG #37942
This program, when running under go 1.14, will show a huge number of SIGURG are received even though none should be (no network IO, no explicit kills).
The reason I found this is that I have a program that happens to use SIGURG as a custom signal like SIGUSR1, which works fine with previous Go releases. I understand that it should probably use SIGUSR1, but still I think os/signal should hide any signals generated by the runtime as it's irrelevant for the user and an implementation detail.
changed the title [-]os/signal.Notfiy: filter out runtime-generated SIGURG?[/-][+]os/signal.Notify: filter out runtime-generated SIGURG?[/+]on Mar 19, 2020
The reason I found this is that I have a program that happens to use SIGURG as a custom signal like SIGUSR1
Right. It was an explicit decision to pass these through to the program, in case the program is using SIGURG. Unfortunately, the runtime can't tell if a signal is "runtime generated" and thus can't filter it out. Because the kernel combines signals, it's not even well-specified what it would mean for a received signal to be runtime-generated because the kernel could have combined a runtime-generated signal with a signal from another source.
@changkun, I don't really understand your program. First, I don't understand the need for Gosched there. There's no tight loop, and even if there were, I don't see what that Gosched would accomplish. Second, if a program is going to subscribe to all signals, rather than passing specific signals of interest to signal.Notify, then it should be prepared to receive any signal. There are lots of reasons lots of signals get sent. For example, if I ran that program in a terminal emulator and started resizing the window, it would begin streaming warnings about unexpected SIGWINCHes.
@minux I don't see how it is possible even in principle for os/signal to filter out signals generated from the runtime package. Do you have any suggestions as to how that could be done?
signal.Notify is to capture process-targeted signal, right? The preemption signals are thread-targeted. Maybe we can filter signals of which sigcode is SI_TKILL (at least on Linux)?
changed the title [-]os/signal.Notify: filter out runtime-generated SIGURG?[/-][+]os/signal: notify should filter out runtime-generated SIGURG[/+]on Mar 20, 2020
Yeah, it's very difficult to filter out runtime-generated SIGURG without
also occasionally remove a real SIGURG.
I guess, a slightly better solutions is to make sure the runtime only uses
SIGURG when it's necessary.
My program can tolerate occasional spurious SIGURG, but in the current
runtime implementation, it's occurring too frequently.
(Just like the example program I posted, it contains enough preempt points
that forced preemption shouldn't be necessary.)
Perhaps we can repurpose this issue to "runtime: only use forced preemption
when necessary"? Thoughts?
@mengzhuo Can you open a separate issue for that? It sounds like the program is having a hard time making progress, which seems more like #37741. Thanks.
Perhaps we can repurpose this issue to "runtime: only use forced preemption when necessary"?
I've considered delaying the first attempt to use signals until some time after we've tried cooperative preemption and it's failed. Most of the time cooperative preemption responds very quickly. I'm not sure what to set that threshold to, though, since every millisecond of delay there is a millisecond added to STW if there's anything not cooperating.
Activity
[-]os/signal.Notfiy: filter out runtime-generated SIGURG?[/-][+]os/signal.Notify: filter out runtime-generated SIGURG?[/+]aclements commentedon Mar 19, 2020
Right. It was an explicit decision to pass these through to the program, in case the program is using SIGURG. Unfortunately, the runtime can't tell if a signal is "runtime generated" and thus can't filter it out. Because the kernel combines signals, it's not even well-specified what it would mean for a received signal to be runtime-generated because the kernel could have combined a runtime-generated signal with a signal from another source.
@changkun, I don't really understand your program. First, I don't understand the need for
Goschedthere. There's no tight loop, and even if there were, I don't see what thatGoschedwould accomplish. Second, if a program is going to subscribe to all signals, rather than passing specific signals of interest tosignal.Notify, then it should be prepared to receive any signal. There are lots of reasons lots of signals get sent. For example, if I ran that program in a terminal emulator and started resizing the window, it would begin streaming warnings about unexpected SIGWINCHes.ianlancetaylor commentedon Mar 19, 2020
@minux I don't see how it is possible even in principle for os/signal to filter out signals generated from the runtime package. Do you have any suggestions as to how that could be done?
cherrymui commentedon Mar 20, 2020
signal.Notifyis to capture process-targeted signal, right? The preemption signals are thread-targeted. Maybe we can filter signals of whichsigcodeisSI_TKILL(at least on Linux)?cherrymui commentedon Mar 20, 2020
That would not work if the kernel combines signals with different
sigcode. Does it?ianlancetaylor commentedon Mar 20, 2020
As far as I can tell, the Linux 5.3.12 kernel does combine signals with a different
si_codevalue. In__send_signalI seeand
where
signals->signalis the set of pending signals.[-]os/signal.Notify: filter out runtime-generated SIGURG?[/-][+]os/signal: notify should filter out runtime-generated SIGURG[/+]minux commentedon Mar 21, 2020
Dummy handler for SIGURG
mengzhuo commentedon Apr 3, 2020
I found a lot of SIGURGs will timeout the runtime/regex testes of mips64le.
The origin test of runtime only takes 43s to finish, now it's 600s.
https://farmer.golang.org/temporarylogs?name=linux-mips64le-mengzhuo&rev=dcf0929de6a12103a8fd7097abd6e797188c366d&st=0xc010fd8ea0
ianlancetaylor commentedon Apr 3, 2020
@mengzhuo Can you open a separate issue for that? It sounds like the program is having a hard time making progress, which seems more like #37741. Thanks.
aclements commentedon Apr 3, 2020
I've considered delaying the first attempt to use signals until some time after we've tried cooperative preemption and it's failed. Most of the time cooperative preemption responds very quickly. I'm not sure what to set that threshold to, though, since every millisecond of delay there is a millisecond added to STW if there's anything not cooperating.
networkimprov commentedon Apr 3, 2020
Could you also provide a build option to enable (or never enable) preemptive? Runtime env flags would presumably override that...
51 remaining items
tt: add ignoring of the SIGURG signal sending by go runtime
tt: add ignoring of the SIGURG signal sending by go runtime
tt: add ignoring of the SIGURG signal sending by go runtime
tt: add ignoring of the SIGURG signal sending by go runtime
tt: add ignoring of the SIGURG signal sending by go runtime
tt: add ignoring of the SIGURG signal sending by go runtime
tt: add ignoring of the SIGURG signal sending by go runtime
Do not forward SIGURG to the child process
Do not forward SIGURG to the child process
Do not forward SIGURG to the child process
Fixed unstable performance suite test cases.
Fixed unstable performance suite test cases. (#1226)
Docs on sig-proxy are wrong, we support TTY
feat: filter only kill signals due to
Disable new signal-based asynchronous goroutine preemption from GO 1.…