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

Fix SIGURG Handling #5233

Merged
merged 2 commits into from
Apr 23, 2020
Merged

Fix SIGURG Handling #5233

merged 2 commits into from
Apr 23, 2020

Conversation

tri-adam
Copy link
Contributor

Ignore SIGURG, which is used for non-cooperative goroutine preemption starting with Go 1.14 (more info available here).

Fixes #5231

@tri-adam tri-adam added this to the 3.6.0 milestone Apr 21, 2020
@tri-adam tri-adam self-assigned this Apr 21, 2020
@tri-adam tri-adam marked this pull request as ready for review April 21, 2020 23:20
Copy link
Collaborator

@cclerget cclerget left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all engine operation MonitorContainer for singularity/fakeroot/oci engines should also ignore this signal to not send it to container processes

EDIT: simplest is to ignore it in master process https://github.com/sylabs/singularity/blob/c4a0dc2fbcd0793d2b2bab6f23af1e639cdc71ba/internal/app/starter/master_linux.go#L127 with a call to signal.Ignore

internal/pkg/runtime/engine/singularity/process_linux.go Outdated Show resolved Hide resolved
@tri-adam
Copy link
Contributor Author

I think all engine operation MonitorContainer for singularity/fakeroot/oci engines should also ignore this signal to not send it to container processes

Makes sense.

EDIT: simplest is to ignore it in master process

https://github.com/sylabs/singularity/blob/c4a0dc2fbcd0793d2b2bab6f23af1e639cdc71ba/internal/app/starter/master_linux.go#L127

with a call to signal.Ignore

I believe this solution would still leave a small window of time whereby a SIGURG could be queued in the signals chan, between calls to signal.Notify() and signal.Ignore().

To ensure MonitorContainer doesn't pass along SIGURG, two options I can see are:

  1. Call signal.Notify() with a specific list of signals to send to signals, which would ensure that signals never receives a SIGURG.
  2. Ensure each implementation of (engine.Operations).MonitorContainer() ignores SIGURG.

It's also worth noting that this new SIGURG behaviour also increases the risk that legitimate signals may be dropped. We are using a channel size of one, and according to the documentation, signals are dropped once the channel buffer is filled. Experimentation shows that a busy Go program can generate many SIGURG signals per second, but only queues a single SIGURG at a time in a channel registered with signal.Notify().

In light of all of that, I propose:

  • Update signals chan to be of size 2, to account for the likelyhood that SIGURG is queued.
  • Ensure each implementation of (engine.Operations).MonitorContainer() ignores SIGURG.

Copy link
Contributor

@dtrudg dtrudg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @tri-adam - Am happy that this works, and has the effect of the point @cclerget was making about filtering more generally, but without the potential for a signal to slip through that you brought up.

@tri-adam
Copy link
Contributor Author

@cclerget can confirm you're good with this as implemented? Will hold off merging until you can weigh in. Thanks!

@cclerget
Copy link
Collaborator

@cclerget can confirm you're good with this as implemented? Will hold off merging until you can weigh in. Thanks!

@tri-adam LGTM

It's also worth noting that this new SIGURG behaviour also increases the risk that legitimate signals may be dropped

I still not understand why Go runtime internal didn't handle it internally, they own the signal handler there is siginfo available and they can use sigqueue to pass a specific value to distinguish this signal ...

@tri-adam tri-adam merged commit 4fb799d into apptainer:master Apr 23, 2020
@tri-adam tri-adam deleted the issue-5231 branch April 23, 2020 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SIGURG Handling with Go >= 1.14
4 participants