1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/pkg
Neil Horman d764d8b166 Ensure that a device mapper task is referenced until task is complete
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>
2017-05-24 11:11:23 -04:00
..
aaparser apparmor: make pkg/aaparser work on read-only root 2017-05-18 00:05:13 +10:00
archive
authorization
broadcaster
chrootarchive
devicemapper Ensure that a device mapper task is referenced until task is complete 2017-05-24 11:11:23 -04:00
directory
discovery
filenotify
fileutils
fsutils
gitutils
homedir
httputils
idtools
ioutils
jsonlog
jsonmessage Update the stream formatter to display custom unit numbers. 2017-05-11 11:13:11 -07:00
listeners
locker
longpath
loopback
mount
namesgenerator
parsers
pidfile
platform
plugingetter
plugins
pools
progress Update the stream formatter to display custom unit numbers. 2017-05-11 11:13:11 -07:00
promise
pubsub
random
reexec
registrar
signal
stdcopy
streamformatter Update the stream formatter to display custom unit numbers. 2017-05-11 11:13:11 -07:00
stringid
stringutils
symlink
sysinfo
system
tailfile
tarsum
templates
term [pkg/term] switch more syscalls to /x/sys/ 2017-05-18 09:02:42 -04:00
testutil
tlsconfig
truncindex
urlutil
useragent
README.md

pkg/ is a collection of utility packages used by the Docker project without being specific to its internals.

Utility packages are kept separate from the docker core codebase to keep it as small and concise as possible. If some utilities grow larger and their APIs stabilize, they may be moved to their own repository under the Docker organization, to facilitate re-use by other projects. However that is not the priority.

The directory pkg is named after the same directory in the camlistore project. Since Brad is a core Go maintainer, we thought it made sense to copy his methods for organizing Go code :) Thanks Brad!

Because utility packages are small and neatly separated from the rest of the codebase, they are a good place to start for aspiring maintainers and contributors. Get in touch if you want to help maintain them!