Skip to content

go1.21 regression: SIGSEGV in testing.(*common).decorate #62666

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

Closed
rfjakob opened this issue Sep 15, 2023 · 2 comments
Closed

go1.21 regression: SIGSEGV in testing.(*common).decorate #62666

rfjakob opened this issue Sep 15, 2023 · 2 comments

Comments

@rfjakob
Copy link

rfjakob commented Sep 15, 2023

Summary: Looks like 81316ff broke gocryptfs -speed . Downstream ticket: rfjakob/gocryptfs#789

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

$ go version
go version go1.21.1 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/jakob/.cache/go-build'
GOENV='/home/jakob/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/jakob/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/jakob/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.1'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/jakob/go/src/github.com/rfjakob/gocryptfs/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1209216281=/tmp/go-build -gno-record-gcc-switches'

What did you do?

git clone https://github.com/rfjakob/gocryptfs.git
cd gocryptfs
./build-without-openssl.bash
./gocryptfs -speed

What did you expect to see?

./gocryptfs -speed
gocryptfs v2.4.0-4-g7fff33a without_openssl; go-fuse v2.3.0; 2023-09-15 go1.20.3 linux/amd64
cpu: Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz; with AES acceleration
AES-GCM-256-OpenSSL       	    N/A
AES-GCM-256-Go            	 999.53 MB/s	(selected in auto mode)
AES-SIV-512-Go            	 159.86 MB/s
XChaCha20-Poly1305-OpenSSL	    N/A
XChaCha20-Poly1305-Go     	 835.61 MB/s	(selected in auto mode)

What did you see instead?

./gocryptfs -speed
gocryptfs v2.4.0-4-g7fff33a without_openssl; go-fuse v2.3.0; 2023-09-15 go1.21.1 linux/amd64
cpu: Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz; with AES acceleration
AES-GCM-256-OpenSSL       	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x5a5de0]

goroutine 19 [running]:
testing.(*common).decorate(0x40d625?, {0xc00001c180, 0x2a}, 0x830601?)
	testing/testing.go:772 +0xa0
testing.(*common).logDepth(0xc0000ea280, {0xc00001c180, 0x2a}, 0x3)
	testing/testing.go:1035 +0x1dd
testing.(*common).log(...)
	testing/testing.go:1004
testing.(*common).Skip(0xc0000ea280, {0xc00003ef08?, 0x48874f?, 0xc00003ef18?})
	testing/testing.go:1089 +0x4a
github.com/rfjakob/gocryptfs/v2/internal/speed.bStupidGCM(0xc0000ea280)
	github.com/rfjakob/gocryptfs/v2/internal/speed/speed.go:129 +0x45
testing.(*B).runN(0xc0000ea280, 0x1)
	testing/benchmark.go:193 +0x102
testing.(*B).run1.func1()
	testing/benchmark.go:233 +0x4e
created by testing.(*B).run1 in goroutine 1
	testing/benchmark.go:226 +0x90
@rfjakob
Copy link
Author

rfjakob commented Sep 15, 2023

gdb:

/usr/local/go/src$ gdb --args gocryptfs /home/jakob/go/src/github.com/rfjakob/gocryptfs -speed
[...]
Reading symbols from gocryptfs...
Loading Go Runtime support.
(gdb) r
Starting program: /ssd2/jakob.donotbackup/go/bin/gocryptfs /home/jakob/go/src/github.com/rfjakob/gocryptfs -speed
[...]
[New LWP 121475]
[New LWP 121476]
[New LWP 121477]
[New LWP 121478]
gocryptfs v2.4.0-4-g7fff33a without_openssl; go-fuse v2.3.0; 2023-09-15 go1.21.1 linux/amd64
cpu: Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz; with AES acceleration
AES-GCM-256-OpenSSL       	[New LWP 121479]

Thread 4 "gocryptfs" received signal SIGSEGV, Segmentation fault.
[Switching to LWP 121477]
0x00000000005a5de0 in testing.(*common).decorate (c=<optimized out>, 
    s="openssl has been disabled at compile-time\n", skip=<optimized out>, ~r0=...)
    at testing/testing.go:772
772			if *fullPath {
(gdb) l
767	func (c *common) decorate(s string, skip int) string {
768		frame := c.frameSkip(skip)
769		file := frame.File
770		line := frame.Line
771		if file != "" {
772			if *fullPath {
773				// If relative path, truncate file name at last file name separator.
774			} else if index := strings.LastIndex(file, "/"); index >= 0 {
775				file = file[index+1:]
776			} else if index = strings.LastIndex(file, "\\"); index >= 0 {

rfjakob added a commit to rfjakob/gocryptfs that referenced this issue Sep 15, 2023
Looks like I should have been calling testing.Init()
all along. From https://pkg.go.dev/testing#Init :

> Init is only needed when calling functions such as
> Benchmark without using "go test".

Fixes: #789
Relates-to: golang/go#62666
rfjakob added a commit to rfjakob/gocryptfs that referenced this issue Sep 15, 2023
Looks like I should have been calling testing.Init()
all along. From https://pkg.go.dev/testing#Init :

> Init is only needed when calling functions such as
> Benchmark without using "go test".

Panic only affected without_openssl builds and looks
like this:

  $ ./gocryptfs -speed
  gocryptfs v2.4.0-2-g8b1c4b0-dirty without_openssl; go-fuse v2.3.0; 2023-09-15 go1.21.1 linux/amd64
  cpu: Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz; with AES acceleration
  AES-GCM-256-OpenSSL             panic: runtime error: invalid memory address or nil pointer dereference
  [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x5a5d20]

  goroutine 7 [running]:
  testing.(*common).decorate(0x40d625?, {0xc00001c150, 0x2a}, 0x830601?)
          testing/testing.go:772 +0xa0
  [...]

Fixes: #789
Relates-to: golang/go#62666
@rfjakob
Copy link
Author

rfjakob commented Sep 15, 2023

Looks like I should have been calling testing.Init(), so this panic is OK as per the docs.

I do now call testing.Init(), and this fixes the issue, so I'm closing the ticket. Maybe other people hitting this will find the commit useful: rfjakob/gocryptfs@3a65627

@rfjakob rfjakob closed this as completed Sep 15, 2023
@golang golang locked and limited conversation to collaborators Sep 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants