Skip to content

Fix SIGCHLD race in signal handler setup#5210

Merged
lifubang merged 1 commit intoopencontainers:mainfrom
lifubang:fix-signal-race
Apr 2, 2026
Merged

Fix SIGCHLD race in signal handler setup#5210
lifubang merged 1 commit intoopencontainers:mainfrom
lifubang:fix-signal-race

Conversation

@lifubang
Copy link
Copy Markdown
Member

@lifubang lifubang commented Apr 1, 2026

This is an alternative to #5206.
Fix: #5208

When signal installation was moved to a goroutine for performance(#4654), containers that exited quickly could complete before SIGCHLD was registered, causing runc to hang waiting for the signal.

This fix ensures SIGCHLD is registered immediately in the main thread before other signals are handled in the goroutine, maintaining performance while guaranteeing no missed SIGCHLD notifications for fast-exiting containers.

Reported-by: Ayato Tokubi atokubi@redhat.com

signals.go Outdated
}
handler := make(chan *signalHandler)

// ensure that we have a large buffer size so that we do not miss any
Copy link
Copy Markdown
Contributor

@kolyshkin kolyshkin Apr 1, 2026

Choose a reason for hiding this comment

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

a very minor nit:

Suggested change
// ensure that we have a large buffer size so that we do not miss any
// Ensure that we have a large buffer size so that we do not miss any

Copy link
Copy Markdown
Contributor

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

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

LGTM

signals.go Outdated
Comment on lines +37 to +38
// setup.
// But `SIGCHLD` is very important, so we need to handle it immediately.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// setup.
// But `SIGCHLD` is very important, so we need to handle it immediately.
- // setup.
+ // setup, except for SIGCHLD which is very important (see #5208).

@kolyshkin kolyshkin requested review from AkihiroSuda and cyphar April 1, 2026 17:47
@kolyshkin kolyshkin added backport/1.3-todo A PR in main branch which needs to be backported to release-1.3 backport/1.4-todo A PR in main branch which needs to backported to release-1.4 backport/1.5-todo A PR in main branch which needs to be backported to release-1.5 labels Apr 1, 2026
@kolyshkin kolyshkin added this to the 1.5.0-rc.2 milestone Apr 1, 2026
@kolyshkin
Copy link
Copy Markdown
Contributor

I want to include this into 1.5.0rc2, @opencontainers/runc-maintainers ptal

@kolyshkin
Copy link
Copy Markdown
Contributor

@lifubang feel free to merge as is or modify the comments, either way is fine with me. Once merged, please open an 1.5 backport, I want to release rc2 asap

When signal installation was moved to a goroutine for performance,
containers that exited quickly could complete before SIGCHLD was
registered, causing runc to hang waiting for the signal.

This fix ensures SIGCHLD is registered immediately in the main thread
before other signals are handled in the goroutine, maintaining performance
while guaranteeing no missed SIGCHLD notifications for fast-exiting
containers.

Reported-by: Ayato Tokubi <atokubi@redhat.com>
Signed-off-by: lifubang <lifubang@acmcoder.com>
@lifubang lifubang merged commit 62d4f14 into opencontainers:main Apr 2, 2026
55 checks passed
@lifubang lifubang added backport/1.3-done A PR in main branch which has been backported to release-1.3 backport/1.4-done A PR in main branch which has been backported to release-1.4 backport/1.5-done A PR in main branch which has been backported to release-1.5 and removed backport/1.3-todo A PR in main branch which needs to be backported to release-1.3 backport/1.4-todo A PR in main branch which needs to backported to release-1.4 backport/1.5-todo A PR in main branch which needs to be backported to release-1.5 labels Apr 2, 2026
@kolyshkin kolyshkin mentioned this pull request Apr 2, 2026
@kolyshkin kolyshkin removed this from the 1.5.0-rc.2 milestone Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/1.3-done A PR in main branch which has been backported to release-1.3 backport/1.4-done A PR in main branch which has been backported to release-1.4 backport/1.5-done A PR in main branch which has been backported to release-1.5 regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

a SIGCHLD race in signal handler setup (regression since runc 1.3.0)

3 participants