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

runtime: msanread segfaults when called without a g #18707

Closed
bcmills opened this issue Jan 18, 2017 · 4 comments

Comments

Projects
None yet
7 participants
@bcmills
Copy link
Member

commented Jan 18, 2017

When building with -buildmode=c-shared, runtime.rt_sigaction ends up calling msanread on its arguments during libpreinit (before the runtime has set up a g).

Unfortunately, msanread assumes that it is always called with a valid g, leading to a segfault.

src/msanshared/msanshared.go:

package main

import "C"

func main() {}

src/msanshared/main.c:

int main() {
  return 0;
}
$ go version
go version devel +c1730ae424 Wed Jan 18 15:40:33 2017 +0000 linux/amd64
$ go env CC
clang-3.8
$ go env GOGCCFLAGS
-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build181672777=/tmp/go-build -gno-record-gcc-switches
$ go build -msan -buildmode=c-shared -o libmsanshared.so src/msanshared/msanshared.go
$ $(go env CC) $(go env GOGCCFLAGS) -fsanitize=memory -o msanshared src/msanshared/main.c libmsanshared.so
$ LD_LIBRARY_PATH=. ./msanshared
Segmentation fault (core dumped)
@bradfitz

This comment has been minimized.

Copy link
Member

commented Jan 19, 2017

No mention of the priority of whether this is a regression from Go 1.7, so I'm going to assume Go 1.9 for now, since Go 1.8rc2 is probably tomorrow.

@bradfitz bradfitz added this to the Go1.9 milestone Jan 19, 2017

@bradfitz

This comment has been minimized.

Copy link
Member

commented Jan 19, 2017

@bcmills

This comment has been minimized.

Copy link
Member Author

commented Jan 19, 2017

It is a regression. Tests which were (at worst) mildly flaky on 1.7 are failing consistently at startup on the 1.8 RC.

@bcmills

This comment has been minimized.

Copy link
Member Author

commented Jan 19, 2017

Not sure why gobot didn't update the comment, but https://go-review.googlesource.com/#/c/35452/ contains a test and a fix.

@gopherbot gopherbot closed this in ea7d9e6 Jan 19, 2017

@golang golang locked and limited conversation to collaborators Jan 19, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.