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

sys/mount_linux: use pipe for communicating mount result #4160

Merged

Conversation

hligit
Copy link
Contributor

@hligit hligit commented Apr 7, 2020

forkAndMountat forks a process to chdir then mount layers. Signals are
blocked (using runtime_beforeFork) during fork.

There is a race condition that the child process finishes before the
parent process is scheduled and can unblock signal handling. The SIGCHLD
signal sent from the finished process may have been delivered to the
shim process's reaper thread and caused the parent process fail with
ECHLD error.

This patch sets up a pipe for communication between child and parent
instead of waiting for child exit status.

Fixes #4009.

@theopenlab-ci
Copy link

theopenlab-ci bot commented Apr 7, 2020

Build succeeded.

@hligit hligit force-pushed the forkmount-use-pipe-instead-wait4 branch from 7bbfb87 to 290b2f7 Compare April 7, 2020 00:52
@theopenlab-ci
Copy link

theopenlab-ci bot commented Apr 7, 2020

Build succeeded.

@AkihiroSuda
Copy link
Member

Do you have tests?

@codecov-io
Copy link

codecov-io commented Apr 7, 2020

Codecov Report

Merging #4160 into master will increase coverage by 3.26%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4160      +/-   ##
==========================================
+ Coverage   42.44%   45.70%   +3.26%     
==========================================
  Files         133      119      -14     
  Lines       15210    12212    -2998     
==========================================
- Hits         6456     5582     -874     
+ Misses       7821     5698    -2123     
+ Partials      933      932       -1     
Flag Coverage Δ
#linux 45.70% <0.00%> (-0.06%) ⬇️
#windows ?
Impacted Files Coverage Δ
sys/mount_linux.go 0.00% <0.00%> (ø)
remotes/docker/fetcher.go 54.11% <0.00%> (-5.41%) ⬇️
remotes/docker/auth.go 63.82% <0.00%> (-3.97%) ⬇️
remotes/docker/status.go 21.42% <0.00%> (-3.58%) ⬇️
remotes/docker/errdesc.go 28.12% <0.00%> (-2.65%) ⬇️
remotes/docker/errcode.go 47.61% <0.00%> (-1.60%) ⬇️
filters/scanner.go 81.35% <0.00%> (-0.85%) ⬇️
platforms/platforms.go 79.41% <0.00%> (-0.81%) ⬇️
platforms/cpuinfo.go 3.57% <0.00%> (-0.72%) ⬇️
errdefs/grpc.go 77.46% <0.00%> (-0.04%) ⬇️
... and 77 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 173cbc1...290b2f7. Read the comment docs.

@hligit
Copy link
Contributor Author

hligit commented Apr 7, 2020

@AkihiroSuda Since the race condition related issue is only reproduced by introducing some delay within the FMountat function, I'm not sure how this particular scenario can be easily tested. Suggestions are welcome.

sys/mount_linux.go Outdated Show resolved Hide resolved
forkAndMountat forks a process to chdir then mount layers. Signals are
blocked (using runtime_beforeFork) during fork.

There is a race condition that the child process finishes before the
parent process is scheduled and can unblock signal handling. The SIGCHLD
signal sent from the finished process may have been delivered to the
shim process's reaper thread and caused the parent process fail with
ECHLD error.

This patch sets up a pipe for communication between child and parent
instead of waiting for child exit status.

Fixes containerd#4009.

Signed-off-by: Haitao Li <hli@atlassian.com>
@hligit hligit force-pushed the forkmount-use-pipe-instead-wait4 branch from 290b2f7 to 35c14c6 Compare April 8, 2020 23:51
@theopenlab-ci
Copy link

theopenlab-ci bot commented Apr 8, 2020

Build succeeded.

Copy link
Member

@fuweid fuweid left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@estesp estesp left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Creating task failed with "failed to find pid"
5 participants