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

cmd/link: sigsegv linking some reflection using code #18250

Closed
mwhudson opened this issue Dec 8, 2016 · 9 comments

Comments

Projects
None yet
3 participants
@mwhudson
Copy link
Contributor

commented Dec 8, 2016

Please answer these questions before submitting your issue. Thanks!

What did you do?

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

mwhudson@aeglos:/opt/opensource/go-test-cases$ cat checkstuff.go
package main

import (
	"fmt"
	"reflect"
)

type C struct {
}

func F(c *C) *C {
	return nil
}

func main() {
	var c *C
	fmt.Println(reflect.TypeOf(F).Out(0) == reflect.TypeOf(c))
}
mwhudson@aeglos:/opt/opensource/go-test-cases$ go run -linkshared checkstuff.go

What did you expect to see?

true

What did you see instead?

# command-line-arguments
go.plugin.tabs: unreachable sym in relocation: type..2nM11zSk
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x5275cb]

goroutine 1 [running]:
cmd/link/internal/ld.relocsym(0xc420072820, 0xc4204d1cc8)
	/opt/opensource/go/src/cmd/link/internal/ld/data.go:600 +0x10bb
cmd/link/internal/ld.(*Link).reloc(0xc420072820)
	/opt/opensource/go/src/cmd/link/internal/ld/data.go:736 +0xc8
cmd/link/internal/ld.Main()
	/opt/opensource/go/src/cmd/link/internal/ld/main.go:207 +0x949
main.main()
	/opt/opensource/go/src/cmd/link/main.go:58 +0xdb

Does this issue reproduce with the latest release (go1.7.4)?

Go 1.7 says "false", which is also wrong.

System details

go version devel +d4b46aa Thu Dec 8 01:36:44 2016 +0000 linux/amd64
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/opt/opensource/gopath"
GORACE=""
GOROOT="/opt/opensource/go"
GOTOOLDIR="/opt/opensource/go/pkg/tool/linux_amd64"
GCCGO="/usr/bin/gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build977155483=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
GOROOT/bin/go version: go version devel +d4b46aa Thu Dec 8 01:36:44 2016 +0000 linux/amd64
GOROOT/bin/go tool compile -V: compile version devel +d4b46aa Thu Dec 8 01:36:44 2016 +0000 X:framepointer
uname -sr: Linux 4.4.0-47-generic
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.1 LTS
Release:	16.04
Codename:	xenial
/lib/x86_64-linux-gnu/libc.so.6: GNU C Library (Ubuntu GLIBC 2.23-0ubuntu4) stable release version 2.23, by Roland McGrath et al.
gdb --version: GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1
@mwhudson

This comment has been minimized.

Copy link
Contributor Author

commented Dec 8, 2016

Paging @crawshaw

@crawshaw

This comment has been minimized.

Copy link
Contributor

commented Dec 8, 2016

Looks like go.plugin.tabs is being marked as reachable in non-plugins. I can fix that easily enough, which will restore the (incorrect) behavior of 1.7.4. CL soonish.

@mwhudson

This comment has been minimized.

Copy link
Contributor Author

commented Dec 8, 2016

Yeah, I'd just blundered my way to that -- it's being marked reachable while laying out the moduledata, which is way too late. I guess the ptab should only be written to the moduledata if it is reachable?

@crawshaw

This comment has been minimized.

Copy link
Contributor

commented Dec 8, 2016

When -buildmode=plugin it's marked as reachable much earlier, that marking in symtab.go is actually redundant. The problem is it's being used when in other buildmodes.

@mwhudson

This comment has been minimized.

Copy link
Contributor Author

commented Dec 8, 2016

Oh heh we have competing fixes, mine is https://go-review.googlesource.com/c/34170/, I'm not especially attached to it though.

@mwhudson

This comment has been minimized.

Copy link
Contributor Author

commented Dec 8, 2016

(although having the test is worthwhile)

@gopherbot

This comment has been minimized.

Copy link

commented Dec 8, 2016

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

@gopherbot

This comment has been minimized.

Copy link

commented Dec 8, 2016

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

@gopherbot gopherbot closed this in 67b2927 Dec 8, 2016

@mwhudson

This comment has been minimized.

Copy link
Contributor Author

commented Dec 8, 2016

I filed #18252 for the problem that is also present in 1.7.4. Not going to get to that today.

@golang golang locked and limited conversation to collaborators Dec 8, 2017

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.