This repository has been archived by the owner on Oct 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Ensure that a device mapper task is referenced until task is complete #4
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DeviceMapper tasks in go use SetFinalizer to clean up C construct counterparts in the C LVM library. While thats well and good, it relies heavily on the exact interpretation of when the golang garbage collector determines that an object is unreachable is subject to reclaimation. While common sense would assert that for stack variables (which these DM tasks always are), are unreachable when the stack frame in which they are declared returns, thats not the case. According to this: https://golang.org/pkg/runtime/#SetFinalizer The garbage collector decides that, if a function calls into a systemcall (which task.run() always will in LVM), and there are no subsequent references to the task variable within that stack frame, then it can be reclaimed. Those conditions are met in several devmapper.go routines, and if the garbage collector runs in the middle of a deviceMapper operation, then the task can be destroyed while the operation is in progress, leading to crashes, failed operations and other unpredictable behavior. The fix is to use the KeepAlive interface: https://golang.org/pkg/runtime/#KeepAlive The KeepAlive method is effectively an empy reference that fools the garbage collector into thinking that a variable is still reachable. By adding a call to KeepAlive in the task.run() method, we can ensure that the garbage collector won't reclaim a task object until its execution within the deviceMapper C library is complete. Signed-off-by: Neil Horman <nhorman@tuxdriver.com> (cherry picked from commit d764d8b)
23 tasks
andrewhsu
pushed a commit
that referenced
this pull request
Jun 1, 2017
Add armhf dockerfiles for deb building Signed-off-by: Eli Uriegas <seemethere101@gmail.com> Upstream-commit: f0c8cea Component: packaging
LGTM integration tests and unit tests are green |
docker-jenkins
pushed a commit
that referenced
this pull request
Jul 6, 2018
…atypes [18.06] Register OCI image media types Upstream-commit: 85b4dbd3db3761dc3e21f3361cf840eefc1e9fb3 Component: engine
ShemTovYosef
referenced
this pull request
in jingxiaolu/docker-ce
Jan 11, 2020
Signed-off-by: l00397676 <lujingxiao@huawei.com>
silvin-lubecki
pushed a commit
to silvin-lubecki/docker-ce
that referenced
this pull request
Jan 30, 2020
Add armhf dockerfiles for deb building Signed-off-by: Eli Uriegas <seemethere101@gmail.com> Upstream-commit: f0c8cea Component: packaging
silvin-lubecki
pushed a commit
to silvin-lubecki/docker-ce
that referenced
this pull request
Jan 30, 2020
Add armhf dockerfiles for deb building Signed-off-by: Eli Uriegas <seemethere101@gmail.com>
silvin-lubecki
pushed a commit
to silvin-lubecki/docker-ce
that referenced
this pull request
Jan 31, 2020
Add armhf dockerfiles for deb building Signed-off-by: Eli Uriegas <seemethere101@gmail.com> (cherry picked from commit f0c8cea) Signed-off-by: Andrew Hsu <andrewhsu@docker.com>
silvin-lubecki
pushed a commit
to silvin-lubecki/docker-ce
that referenced
this pull request
Feb 3, 2020
Ensure that a device mapper task is referenced until task is complete
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
DeviceMapper tasks in go use SetFinalizer to clean up C construct
counterparts in the C LVM library. While thats well and good, it relies
heavily on the exact interpretation of when the golang garbage collector
determines that an object is unreachable is subject to reclaimation.
While common sense would assert that for stack variables (which these DM
tasks always are), are unreachable when the stack frame in which they
are declared returns, thats not the case. According to this:
https://golang.org/pkg/runtime/#SetFinalizer
The garbage collector decides that, if a function calls into a
systemcall (which task.run() always will in LVM), and there are no
subsequent references to the task variable within that stack frame, then
it can be reclaimed. Those conditions are met in several devmapper.go
routines, and if the garbage collector runs in the middle of a
deviceMapper operation, then the task can be destroyed while the
operation is in progress, leading to crashes, failed operations and
other unpredictable behavior.
The fix is to use the KeepAlive interface:
https://golang.org/pkg/runtime/#KeepAlive
The KeepAlive method is effectively an empy reference that fools the
garbage collector into thinking that a variable is still reachable. By
adding a call to KeepAlive in the task.run() method, we can ensure that
the garbage collector won't reclaim a task object until its execution
within the deviceMapper C library is complete.
Signed-off-by: Neil Horman nhorman@tuxdriver.com
(cherry picked from commit d764d8b)
--
Cherry pick of moby/moby#33376