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

runtime: don't spawn threads from locked Ms #20676

Closed
aclements opened this Issue Jun 14, 2017 · 4 comments

Comments

Projects
None yet
5 participants
@aclements
Member

aclements commented Jun 14, 2017

Currently the runtime can spawn a new OS thread from essentially any M. This is bad if it attempts to spawn from a locked M that's locked because the goroutine on that M put the OS thread into a strange state. The new thread will inherit this state and start running other goroutines.

For example, this blog post describes the effects of this when trying to manipulate Linux namespaces from within a goroutine: https://www.weave.works/blog/linux-namespaces-and-go-don-t-mix

We should instead make sure we never spawn new threads from locked Ms. If we need to start a new thread while running on a locked M, we should forward the clone operation to a known-clean thread. We could either keep around a thread specifically for this purpose, or use the existing sysmon thread.

This is related to #20395, which is the other way a tainted thread can wind up back in the runtime's thread pool.

@aclements aclements added this to the Go1.10 milestone Jun 14, 2017

@aclements aclements self-assigned this Jun 14, 2017

@gopherbot

This comment has been minimized.

gopherbot commented Jun 16, 2017

CL https://golang.org/cl/46033 mentions this issue.

mcwumbly added a commit to cloudfoundry/silk that referenced this issue Jun 21, 2017

[cni] Use container IP from store for IFB delete
Instead of switching into the container namespace
and getting the IP addresses from the device, lookup
the container metadata in our own datastore.

This avoids switching namespaces and simplifies the IFB
delete code a bit.

See also: golang/go#20676

[#145244693]
@jessfraz

This comment has been minimized.

Contributor

jessfraz commented Jul 15, 2017

cc @LK4D4 just figured you would be curious

@markdascher

This comment has been minimized.

markdascher commented Aug 26, 2017

This is related to #13164, which was solved a different way.

Looks like the proposed solution has the same idea, just using an entire spare thread as the "known good" state instead of just initSigmask, which is likely to be redundant after this fix goes in. (Because ensureSigM calls LockOSThread already.)

@gopherbot gopherbot closed this in 2595fe7 Oct 11, 2017

jodh-intel added a commit to jodh-intel/runtimes that referenced this issue Sep 18, 2018

versions: Update golang to 1.10.4
Move to golang version 1.10.4 -- the oldest stable golang release at the
time of writing -- since golang 1.10+ is needed to make namespace
handling safe.

See:

- golang/go#20676
- golang/go@2595fe7

Also bumped `languages.golang.meta.newest-version` to golang version
1.11, which is the newest stable release at the time of writing.

Fixes kata-containers#148.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
@wsc1

This comment has been minimized.

wsc1 commented Sep 19, 2018

Just wanted to note this related message on golang-dev, as the notion of "clean thread" may be manipulated anyway via scheduling inheritance via pthread_attr or chrt linux and the like. Seems to me like a necessary and useful feature to isolate thread properties from threads created via package "C", but not via the OS.

jodh-intel added a commit to jodh-intel/runtimes that referenced this issue Sep 20, 2018

versions: Update golang to 1.10.4
Move to golang version 1.10.4 -- the oldest stable golang release at the
time of writing -- since golang 1.10+ is needed to make namespace
handling safe.

Re-ordered a couple of structs (moved `sync.WaitGroup` fields) to keep
the `maligned` linter happy. Previously:

``
virtcontainers/pkg/mock/cc_proxy_mock.go:24:18⚠️ struct of size 160 could be 152 (maligned)
virtcontainers/monitor.go:15:14⚠️ struct of size 80 could be 72 (maligned)
```

See:

- golang/go#20676
- golang/go@2595fe7

Also bumped `languages.golang.meta.newest-version` to golang version
1.11, which is the newest stable release at the time of writing.

Fixes kata-containers#148.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>

jodh-intel added a commit to jodh-intel/runtimes that referenced this issue Sep 20, 2018

versions: Update golang to 1.10.4
Move to golang version 1.10.4 -- the oldest stable golang release at the
time of writing -- since golang 1.10+ is needed to make namespace
handling safe.

Re-ordered a couple of structs (moved `sync.WaitGroup` fields) to keep
the `maligned` linter happy. Previously:

``
virtcontainers/pkg/mock/cc_proxy_mock.go:24:18⚠️ struct of size 160 could be 152 (maligned)
virtcontainers/monitor.go:15:14⚠️ struct of size 80 could be 72 (maligned)
```

See:

- golang/go#20676
- golang/go@2595fe7

Also bumped `languages.golang.meta.newest-version` to golang version
1.11, which is the newest stable release at the time of writing.

Fixes kata-containers#148.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>

jodh-intel added a commit to jodh-intel/runtimes that referenced this issue Oct 23, 2018

versions: Update golang to 1.10.4
Move to golang version 1.10.4 -- the oldest stable golang release at the
time of writing -- since golang 1.10+ is needed to make namespace
handling safe.

Re-ordered a couple of structs (moved `sync.WaitGroup` fields) to keep
the `maligned` linter happy. Previously:

``
virtcontainers/pkg/mock/cc_proxy_mock.go:24:18⚠️ struct of size 160 could be 152 (maligned)
virtcontainers/monitor.go:15:14⚠️ struct of size 80 could be 72 (maligned)
```

See:

- golang/go#20676
- golang/go@2595fe7

Also bumped `languages.golang.meta.newest-version` to golang version
1.11, which is the newest stable release at the time of writing.

Fixes kata-containers#148.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>

jodh-intel added a commit to jodh-intel/runtimes that referenced this issue Oct 23, 2018

versions: Update golang to 1.10.4
Move to golang version 1.10.4 -- the oldest stable golang release at the
time of writing -- since golang 1.10+ is needed to make namespace
handling safe.

Re-ordered a couple of structs (moved `sync.WaitGroup` fields) to keep
the `maligned` linter happy. Previously:

``
virtcontainers/pkg/mock/cc_proxy_mock.go:24:18⚠️ struct of size 160 could be 152 (maligned)
virtcontainers/monitor.go:15:14⚠️ struct of size 80 could be 72 (maligned)
```

See:

- golang/go#20676
- golang/go@2595fe7

Also bumped `languages.golang.meta.newest-version` to golang version
1.11, which is the newest stable release at the time of writing.

Fixes kata-containers#148.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>

jodh-intel added a commit to jodh-intel/runtimes that referenced this issue Oct 23, 2018

versions: Update golang to 1.10.4
Move to golang version 1.10.4 -- the oldest stable golang release at the
time of writing -- since golang 1.10+ is needed to make namespace
handling safe.

Re-ordered a couple of structs (moved `sync.WaitGroup` fields) to keep
the `maligned` linter happy. Previously:

``
virtcontainers/pkg/mock/cc_proxy_mock.go:24:18⚠️ struct of size 160 could be 152 (maligned)
virtcontainers/monitor.go:15:14⚠️ struct of size 80 could be 72 (maligned)
```

See:

- golang/go#20676
- golang/go@2595fe7

Also bumped `languages.golang.meta.newest-version` to golang version
1.11, which is the newest stable release at the time of writing.

Fixes kata-containers#148.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>

jodh-intel added a commit to jodh-intel/runtimes that referenced this issue Oct 23, 2018

versions: Update golang to 1.10.4
Move to golang version 1.10.4 -- the oldest stable golang release at the
time of writing -- since golang 1.10+ is needed to make namespace
handling safe.

Re-ordered a couple of structs (moved `sync.WaitGroup` fields) to keep
the `maligned` linter happy. Previously:

``
virtcontainers/pkg/mock/cc_proxy_mock.go:24:18⚠️ struct of size 160 could be 152 (maligned)
virtcontainers/monitor.go:15:14⚠️ struct of size 80 could be 72 (maligned)
```

See:

- golang/go#20676
- golang/go@2595fe7

Also bumped `languages.golang.meta.newest-version` to golang version
1.11, which is the newest stable release at the time of writing.

Fixes kata-containers#148.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>

zklei added a commit to zklei/runtime that referenced this issue Nov 22, 2018

versions: Update golang to 1.10.4
Move to golang version 1.10.4 -- the oldest stable golang release at the
time of writing -- since golang 1.10+ is needed to make namespace
handling safe.

Re-ordered a couple of structs (moved `sync.WaitGroup` fields) to keep
the `maligned` linter happy. Previously:

``
virtcontainers/pkg/mock/cc_proxy_mock.go:24:18⚠️ struct of size 160 could be 152 (maligned)
virtcontainers/monitor.go:15:14⚠️ struct of size 80 could be 72 (maligned)
```

See:

- golang/go#20676
- golang/go@2595fe7

Also bumped `languages.golang.meta.newest-version` to golang version
1.11, which is the newest stable release at the time of writing.

Fixes kata-containers#148.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment