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: binaries packed with UPX run into segfault with 1.8 #19625

Closed
unclejack opened this issue Mar 20, 2017 · 4 comments
Closed

cmd/link: binaries packed with UPX run into segfault with 1.8 #19625

unclejack opened this issue Mar 20, 2017 · 4 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@unclejack
Copy link
Contributor

What version of Go are you using (go version)?

go version go1.8 linux/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build006597881=/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"

What did you do?

foo.go:

package main

import "fmt"

func main() {
        fmt.Println("asd")
}

https://play.golang.org/p/4tyqhiibb5

$ go build foo.go
$ upx foo
$ ./foo
Segmentation fault (core dumped)

What did you expect to see?

I expected to see "asd" printed.

What did you see instead?

Segmentation fault (core dumped)

@bradfitz
Copy link
Contributor

Have you filed a bug against upx?

@bradfitz bradfitz added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Mar 20, 2017
@unclejack
Copy link
Contributor Author

@bradfitz: I haven't filed a bug against UPX because this was working properly with Go 1.7.5. I don't have a strong opinion related to this. Some use UPX to get smaller binaries. It seemed to be a good idea to bring this up since Go 1.8.1 is the next release. I didn't know whether this was a known issue or not.

Please feel free to close this immediately if it's not considered an issue or a bug.

@bradfitz
Copy link
Contributor

We don't maintain UPX. If things worked or didn't work at some point, that's either luck or it's because UPX did or didn't support something at one point.

I'll close this until there's any evidence that Go is violating some ELF spec or something.

@krzysztofantczak
Copy link

krzysztofantczak commented Aug 5, 2017

@unclejack FYI - just had the same problem, but i was using the same GO version on my old app and new one which was very similar to yours - simple "hello world". It seems that it throws "core dumped" when GO binary is too small ;-)

Go binary size: 3,7M - after UPX: 897K - core dumped
Go binary size: 22M - after UPX: 4,7M - works perfectly fine.

No idea where's the actual border line for UPX to make things work, i had not that much time to play with it.

Tested with:
go1.8 linux/amd64
upx 3.91

EDIT:
I made some additional test. I picked up some large package and made sure that it wont run right away, but it will be compiled in (perhaps there's better way to do that):
https://gist.github.com/krzysztofantczak/511cb87fc545f23ceb44ce6e8bf90d6c

I took this code from softlayer repo, just to trigger their package for compiler and test it against UPX.

11M before UPX, 2,4M after UPX - works but kinda pointless in this kind of small app - should work with real one thought.

@golang golang locked and limited conversation to collaborators Aug 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants