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: TestGdbPythonCgo fails on x1 Linux #27608

Closed
mewmew opened this issue Sep 11, 2018 · 10 comments

Comments

Projects
None yet
6 participants
@mewmew
Copy link
Contributor

commented Sep 11, 2018

Please answer these questions before submitting your issue. Thanks!

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

u@x1 ~> go version
go version devel +0f72e79856 Mon Sep 10 18:29:25 2018 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes, I'm at tip.

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

u@x1 ~> go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/u/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/u/goget:/home/u/Desktop/go"
GOPROXY=""
GORACE=""
GOROOT="/home/u/go1.11"
GOTMPDIR=""
GOTOOLDIR="/home/u/go1.11/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build981071405=/tmp/go-build -gno-record-gcc-switches"

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.

Try to install the latest version of Go from source, running all.bash.

What did you expect to see?

PASS.

What did you see instead?

--- FAIL: TestGdbPythonCgo (4.15s)
    runtime-gdb_test.go:64: gdb version 8.2
    runtime-gdb_test.go:213: gdb output: Loading Go Runtime support.
        Loading Go Runtime support.
        Breakpoint 1 at 0x47f7e0: file /home/u/go1.11/src/fmt/print.go, line 263.
        [Thread debugging using libthread_db enabled]
        Using host libthread_db library "/usr/lib/libthread_db.so.1".
        [New Thread 0x7ffff5b5d700 (LWP 20547)]
        [New Thread 0x7ffff535c700 (LWP 20548)]
        [New Thread 0x7ffff4b5b700 (LWP 20549)]
        [New Thread 0x7fffeffff700 (LWP 20550)]
        [New Thread 0x7fffef7fe700 (LWP 20559)]
        
        Thread 1 "a.exe" hit Breakpoint 1, fmt.Println (a=..., n=<optimized out>, err=...) at /home/u/go1.11/src/fmt/print.go:263
        263	func Println(a ...interface{}) (n int, err error) {
        BEGIN info goroutines
        * 1 running  runtime.systemstack_switch
          2 waiting  runtime.gopark
          3 waiting  runtime.gopark
          4 runnable runtime.runfinq
        END
        #1  0x0000000000486030 in main.main () at /tmp/go-build749260972/main.go:15
        15		fmt.Println("hi")
        BEGIN print mapvar
        $1 = map[string]string = {[0x4b675e "abc"] = 0x4b676a "def", [0x4b6776 "ghi"] = 0x4b677f "jkl"}
        END
        BEGIN print strvar
        $2 = 0x4b675e "abc"
        END
        BEGIN info locals
        slicevar = {array = 0xc00008a000, len = 1, cap = 16}
        mapvar = map[string]string = {[0x4b675e "abc"] = 0x4b676a "def", [0x4b6776 "ghi"] = 0x4b677f "jkl"}
        strvar = 0x4b675e "abc"
        END
        #0  fmt.Println (a=..., n=<optimized out>, err=...) at /home/u/go1.11/src/fmt/print.go:263
        263	func Println(a ...interface{}) (n int, err error) {
        BEGIN goroutine 1 bt
        #0  fmt.Println (a=..., n=<optimized out>, err=...) at /home/u/go1.11/src/fmt/print.go:263
        #1  0x0000000000486030 in main.main () at /tmp/go-build749260972/main.go:15
        END
        BEGIN goroutine 2 bt
        #0  runtime.gopark (unlockf=<optimized out>, lock=0x54fdc0 <runtime.forcegc>, reason=16 '\020', traceEv=20 '\024', traceskip=1) at /home/u/go1.11/src/runtime/proc.go:303
        #1  0x000000000042a613 in runtime.goparkunlock (lock=<optimized out>, reason=<optimized out>, traceEv=<optimized out>, traceskip=<optimized out>) at /home/u/go1.11/src/runtime/proc.go:308
        #2  0x000000000042a3e3 in runtime.forcegchelper () at /home/u/go1.11/src/runtime/proc.go:251
        #3  0x0000000000451db1 in runtime.goexit () at /home/u/go1.11/src/runtime/asm_amd64.s:1340
        #4  0x0000000000000000 in ?? ()
        END
        Breakpoint 2 at 0x48605d: file /tmp/go-build749260972/main.go, line 20.
        hi
        
        Thread 1 "a.exe" hit Breakpoint 2, main.main () at /tmp/go-build749260972/main.go:20
        20	}  // END_OF_PROGRAM
        BEGIN goroutine 1 bt at the end
        #0  main.main () at /tmp/go-build749260972/main.go:20
        END
        
    runtime-gdb_test.go:249: print mapvar failed: $1 = map[string]string = {[0x4b675e "abc"] = 0x4b676a "def", [0x4b6776 "ghi"] = 0x4b677f "jkl"}
--- FAIL: TestGdbAutotmpTypes (3.64s)
    runtime-gdb_test.go:64: gdb version 8.2
    runtime-gdb_test.go:436: could not find struct []main.astruct; in 'info typrs astruct' output
    runtime-gdb_test.go:437: gdb output:
        Loading Go Runtime support.
        Breakpoint 1 at 0x454730: file /tmp/go-build271197886/main.go, line 8.
        [New LWP 20965]
        [New LWP 20970]
        [New LWP 20981]
        [New LWP 20980]
        [New LWP 20986]
        
        Thread 1 "a.exe" hit Breakpoint 1, main.main () at /tmp/go-build271197886/main.go:8
        8	func main() {
        9		var iface interface{} = map[string]astruct{}
        All types matching regular expression "astruct":
        
        File internal/cpu:
        	[]main.astruct;
        	bucket<string,main.astruct>;
        	hash<string,main.astruct>;
        	main.astruct;
        	typedef hash<string,main.astruct> * map[string]main.astruct;
        	typedef noalg.[8]main.astruct noalg.[8]main.astruct;
        	noalg.map.bucket[string]main.astruct;
        	noalg.map.hdr[string]main.astruct;
--- FAIL: TestGdbPython (1.71s)
    runtime-gdb_test.go:64: gdb version 8.2
    runtime-gdb_test.go:213: gdb output: Loading Go Runtime support.
        Loaded  Script                                                                 
        Yes     /home/u/go1.11/src/runtime/runtime-gdb.py                              
        Breakpoint 1 at 0x47dda0: file /home/u/go1.11/src/fmt/print.go, line 263.
        [New LWP 21015]
        [New LWP 21016]
        [New LWP 21017]
        [New LWP 21018]
        
        Thread 1 "a.exe" hit Breakpoint 1, fmt.Println (a=..., n=<optimized out>, err=...) at /home/u/go1.11/src/fmt/print.go:263
        263	func Println(a ...interface{}) (n int, err error) {
        BEGIN info goroutines
        * 1 running  runtime.systemstack_switch
          2 waiting  runtime.gopark
          3 waiting  runtime.gopark
          4 runnable runtime.runfinq
        END
        #1  0x00000000004845f0 in main.main () at /tmp/go-build163811488/main.go:14
        14		fmt.Println("hi")
        BEGIN print mapvar
        $1 = map[string]string = {[0x4b473e "abc"] = 0x4b474a "def", [0x4b4756 "ghi"] = 0x4b475f "jkl"}
        END
        BEGIN print strvar
        $2 = 0x4b473e "abc"
        END
        BEGIN info locals
        slicevar = {array = 0xc00007e000, len = 1, cap = 16}
        mapvar = map[string]string = {[0x4b473e "abc"] = 0x4b474a "def", [0x4b4756 "ghi"] = 0x4b475f "jkl"}
        strvar = 0x4b473e "abc"
        END
        #0  fmt.Println (a=..., n=<optimized out>, err=...) at /home/u/go1.11/src/fmt/print.go:263
        263	func Println(a ...interface{}) (n int, err error) {
        BEGIN goroutine 1 bt
        #0  fmt.Println (a=..., n=<optimized out>, err=...) at /home/u/go1.11/src/fmt/print.go:263
        #1  0x00000000004845f0 in main.main () at /tmp/go-build163811488/main.go:14
        END
        BEGIN goroutine 2 bt
        #0  runtime.gopark (unlockf=<optimized out>, lock=0x54bc70 <runtime.forcegc>, reason=16 '\020', traceEv=20 '\024', traceskip=1) at /home/u/go1.11/src/runtime/proc.go:303
        #1  0x0000000000428e03 in runtime.goparkunlock (lock=<optimized out>, reason=<optimized out>, traceEv=<optimized out>, traceskip=<optimized out>) at /home/u/go1.11/src/runtime/proc.go:308
        #2  0x0000000000428bd3 in runtime.forcegchelper () at /home/u/go1.11/src/runtime/proc.go:251
        #3  0x0000000000450411 in runtime.goexit () at /home/u/go1.11/src/runtime/asm_amd64.s:1340
        #4  0x0000000000000000 in ?? ()
        END
        Breakpoint 2 at 0x48461d: file /tmp/go-build163811488/main.go, line 19.
        hi
        
        Thread 1 "a.exe" hit Breakpoint 2, main.main () at /tmp/go-build163811488/main.go:19
        19	}  // END_OF_PROGRAM
        BEGIN goroutine 1 bt at the end
        #0  main.main () at /tmp/go-build163811488/main.go:19
        END
        
    runtime-gdb_test.go:249: print mapvar failed: $1 = map[string]string = {[0x4b473e "abc"] = 0x4b474a "def", [0x4b4756 "ghi"] = 0x4b475f "jkl"}
FAIL
FAIL	runtime	43.147s
@shuLhan

This comment has been minimized.

Copy link
Contributor

commented Sep 12, 2018

I am currently working on patching this. Seems like the new gdb add address on map key and value, and the "info local" has different output.

@gopherbot

This comment has been minimized.

Copy link

commented Sep 12, 2018

Change https://golang.org/cl/135055 mentions this issue: runtime: fix runtime gdb test with gdb v8.2

@mewmew

This comment has been minimized.

Copy link
Contributor Author

commented Oct 1, 2018

I can confirm that the issue is resolved at a9c69e0, and was present at 43cd907.

Thanks! Finally back to the welcoming ALL TESTS PASSED

@darcosion

This comment has been minimized.

Copy link

commented Nov 9, 2018

Hello.

I Have the same error in an Ubuntu-like :

    runtime-gdb_test.go:64: gdb version 8.2
    runtime-gdb_test.go:213: gdb output: Loading Go Runtime support.
        Loading Go Runtime support.
        Breakpoint 1 at 0x47f5d0: file /home/user123/go/go/src/fmt/print.go, line 263.
        [Thread debugging using libthread_db enabled]
        Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
        [New Thread 0x7ffff55df700 (LWP 30948)]
        [New Thread 0x7ffff4dde700 (LWP 30952)]
        [New Thread 0x7ffff45dd700 (LWP 30955)]
        [New Thread 0x7ffff3ddc700 (LWP 30956)]
        [New Thread 0x7ffff35db700 (LWP 30957)]
        
        Thread 1 "a.exe" hit Breakpoint 1, fmt.Println (a=..., err=..., n=<optimized out>) at /home/user123/go/go/src/fmt/print.go:263
        263	func Println(a ...interface{}) (n int, err error) {
        BEGIN info goroutines
        * 1 running  runtime.systemstack_switch
          2 waiting  runtime.gopark
          3 waiting  runtime.gopark
          4 waiting  runtime.gopark
        END
        #1  0x0000000000485f50 in main.main () at /tmp/go-build599244139/main.go:15
        15		fmt.Println("hi")
        BEGIN print mapvar
        $1 = map[string]string = {[0x4b5a7e "abc"] = 0x4b5a8a "def", [0x4b5a96 "ghi"] = 0x4b5a9f "jkl"}
        END
        BEGIN print strvar
        $2 = 0x4b5a7e "abc"
        END
        BEGIN info locals
        mapvar = map[string]string = {[0x4b5a7e "abc"] = 0x4b5a8a "def", [0x4b5a96 "ghi"] = 0x4b5a9f "jkl"}
        slicevar = {array = 0xc00008c000, len = 1, cap = 16}
        strvar = 0x4b5a7e "abc"
        END
        #0  fmt.Println (a=..., err=..., n=<optimized out>) at /home/user123/go/go/src/fmt/print.go:263
        263	func Println(a ...interface{}) (n int, err error) {
        BEGIN goroutine 1 bt
        #0  fmt.Println (a=..., err=..., n=<optimized out>) at /home/user123/go/go/src/fmt/print.go:263
        #1  0x0000000000485f50 in main.main () at /tmp/go-build599244139/main.go:15
        END
        BEGIN goroutine 2 bt
        #0  runtime.gopark (lock=0x74ddc0 <runtime.forcegc>, reason=16 '\020', traceEv=20 '\024', traceskip=1, unlockf=<optimized out>) at /home/user123/go/go/src/runtime/proc.go:303
        #1  0x0000000000429c13 in runtime.goparkunlock (lock=<optimized out>, reason=<optimized out>, traceEv=<optimized out>, traceskip=<optimized out>) at /home/user123/go/go/src/runtime/proc.go:308
        #2  0x00000000004299e3 in runtime.forcegchelper () at /home/user123/go/go/src/runtime/proc.go:251
        #3  0x0000000000451961 in runtime.goexit () at /home/user123/go/go/src/runtime/asm_amd64.s:1333
        #4  0x0000000000000000 in ?? ()
        END
        Breakpoint 2 at 0x485f7d: file /tmp/go-build599244139/main.go, line 20.
        hi
        
        Thread 1 "a.exe" hit Breakpoint 2, main.main () at /tmp/go-build599244139/main.go:20
        20	}  // END_OF_PROGRAM
        BEGIN goroutine 1 bt at the end
        #0  main.main () at /tmp/go-build599244139/main.go:20
        END
        
    runtime-gdb_test.go:249: print mapvar failed: $1 = map[string]string = {[0x4b5a7e "abc"] = 0x4b5a8a "def", [0x4b5a96 "ghi"] = 0x4b5a9f "jkl"}
--- FAIL: TestGdbAutotmpTypes (16.99s)
    runtime-gdb_test.go:64: gdb version 8.2
    runtime-gdb_test.go:436: could not find struct []main.astruct; in 'info typrs astruct' output
    runtime-gdb_test.go:437: gdb output:
        Loading Go Runtime support.
        Breakpoint 1 at 0x4547b0: file /tmp/go-build002571580/main.go, line 8.
        [New LWP 31130]
        [New LWP 31131]
        [New LWP 31132]
        [New LWP 31133]
        [New LWP 31134]
        
        Thread 1 "a.exe" hit Breakpoint 1, main.main () at /tmp/go-build002571580/main.go:8
        8	func main() {
        9		var iface interface{} = map[string]astruct{}
        All types matching regular expression "astruct":
        
        File internal/cpu:
        	[]main.astruct;
        	bucket<string,main.astruct>;
        	hash<string,main.astruct>;
        	main.astruct;
        	typedef hash<string,main.astruct> * map[string]main.astruct;
        	typedef noalg.[8]main.astruct noalg.[8]main.astruct;
        	noalg.map.bucket[string]main.astruct;
        	noalg.map.hdr[string]main.astruct;
--- FAIL: TestGdbPython (6.21s)
    runtime-gdb_test.go:64: gdb version 8.2
    runtime-gdb_test.go:213: gdb output: Loading Go Runtime support.
        Loaded  Script                                                                 
        Yes     /home/user123/go/go/src/runtime/runtime-gdb.py                          
        Breakpoint 1 at 0x47e800: file /home/user123/go/go/src/fmt/print.go, line 263.
        [New LWP 31227]
        [New LWP 31228]
        [New LWP 31229]
        [New LWP 31230]
        [New LWP 31231]
        
        Thread 1 "a.exe" hit Breakpoint 1, fmt.Println (a=..., err=..., n=<optimized out>) at /home/user123/go/go/src/fmt/print.go:263
        263	func Println(a ...interface{}) (n int, err error) {
        BEGIN info goroutines
        * 1 running  runtime.systemstack_switch
          2 waiting  runtime.gopark
          17 waiting  runtime.gopark
          3 runnable runtime.runfinq
        END
        #1  0x0000000000485180 in main.main () at /tmp/go-build054279216/main.go:14
        14		fmt.Println("hi")
        BEGIN print mapvar
        $1 = map[string]string = {[0x4b509e "abc"] = 0x4b50aa "def", [0x4b50b6 "ghi"] = 0x4b50bf "jkl"}
        END
        BEGIN print strvar
        $2 = 0x4b509e "abc"
        END
        BEGIN info locals
        mapvar = map[string]string = {[0x4b509e "abc"] = 0x4b50aa "def", [0x4b50b6 "ghi"] = 0x4b50bf "jkl"}
        slicevar = {array = 0xc00008c000, len = 1, cap = 16}
        strvar = 0x4b509e "abc"
        END
        #0  fmt.Println (a=..., err=..., n=<optimized out>) at /home/user123/go/go/src/fmt/print.go:263
        263	func Println(a ...interface{}) (n int, err error) {
        BEGIN goroutine 1 bt
        #0  fmt.Println (a=..., err=..., n=<optimized out>) at /home/user123/go/go/src/fmt/print.go:263
        #1  0x0000000000485180 in main.main () at /tmp/go-build054279216/main.go:14
        END
        BEGIN goroutine 2 bt
        #0  runtime.gopark (lock=0x54bc70 <runtime.forcegc>, reason=16 '\020', traceEv=20 '\024', traceskip=1, unlockf=<optimized out>) at /home/user123/go/go/src/runtime/proc.go:303
        #1  0x0000000000429083 in runtime.goparkunlock (lock=<optimized out>, reason=<optimized out>, traceEv=<optimized out>, traceskip=<optimized out>) at /home/user123/go/go/src/runtime/proc.go:308
        #2  0x0000000000428e53 in runtime.forcegchelper () at /home/user123/go/go/src/runtime/proc.go:251
        #3  0x0000000000450c31 in runtime.goexit () at /home/user123/go/go/src/runtime/asm_amd64.s:1333
        #4  0x0000000000000000 in ?? ()
        END
        Breakpoint 2 at 0x4851ad: file /tmp/go-build054279216/main.go, line 19.
        hi
        
        Thread 1 "a.exe" hit Breakpoint 2, main.main () at /tmp/go-build054279216/main.go:19
        19	}  // END_OF_PROGRAM
        BEGIN goroutine 1 bt at the end
        #0  main.main () at /tmp/go-build054279216/main.go:19
        END
        
    runtime-gdb_test.go:249: print mapvar failed: $1 = map[string]string = {[0x4b509e "abc"] = 0x4b50aa "def", [0x4b50b6 "ghi"] = 0x4b50bf "jkl"}
FAIL
FAIL	runtime	101.529s
@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Nov 9, 2018

@darcosion This issue is closed and is believed to be fixed. You didn't mention which version you are running: is it before or after the fix, which went into the tree for the future 1.12 on October 1?

@darcosion

This comment has been minimized.

Copy link

commented Nov 9, 2018

Oh, I'm in the 1.11. I think it's the problem.

Thanks for this response.

@jimrobinson

This comment has been minimized.

Copy link

commented Nov 27, 2018

I think the fix is still fragile. The patched version still isn't fixed my gdb's output. What I see my gdb 8.2-3 producing for "info locals" is:

mapvar = map[string]string = {[0x4b70be "abc"] = 0x4b70ca "def", [0x4b70d6 "ghi"] = 0x4b70df "jkl"}
slicevar = {array = 0xc000116000, len = 1, cap = 16}
strvar = 0x4b70be "abc"

which does not match the pair of infoLocalsRe test expressions:

infoLocalsRe1 := regexp.MustCompile(`slicevar *= *\[\]string *= *{"def"}`)
...
infoLocalsRe2 := regexp.MustCompile(`^slicevar = .*\nmapvar = .*\nstrvar = 0x[0-9a-f]+ "abc"`)

It seems as though the gdb 8.2 @shuLhan tested against produced slicevar and then mapvar, whereas with my instance it's producing mapvar then slicevar.

My version of gdb is from fedora 29

# gdb --version
GNU gdb (GDB) Fedora 8.2-3.fc29
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Layering even more re complexity into this seems like a bad idea, but here's an re that tries to accommodate mapvar appearing either before or after the slicevar, or not appearing at all:

--- runtime-gdb_test.go.27608	2018-11-26 23:11:15.291620507 -0800
+++ runtime-gdb_test.go	2018-11-27 00:13:44.831368390 -0800
@@ -265,7 +265,7 @@
 
 	infoLocalsRe1 := regexp.MustCompile(`slicevar *= *\[\]string *= *{"def"}`)
 	// Format output from gdb v8.2
-	infoLocalsRe2 := regexp.MustCompile(`^slicevar = .*\nmapvar = .*\nstrvar = 0x[0-9a-f]+ "abc"`)
+	infoLocalsRe2 := regexp.MustCompile(`^(mapvar = .+\n)?slicevar = .+\n(mapvar = .+\n)?strvar = 0x[0-9a-f]+ "abc"`)
 	if bl := blocks["info locals"]; !infoLocalsRe1.MatchString(bl) &&
 		!infoLocalsRe2.MatchString(bl) {
 		t.Fatalf("info locals failed: %s", bl)
@shuLhan

This comment has been minimized.

Copy link
Contributor

commented Nov 27, 2018

@jimrobinson If you recompiling Go from source (using master branch, not Go 1.1x source), make sure you fetch the latest commits. The test conditional checks in testGdbPython has been changed. [1] Both my patch and your patch is no longer valid.

[1] https://github.com/golang/go/blob/master/src/runtime/runtime-gdb_test.go#L269

@jimrobinson

This comment has been minimized.

Copy link

commented Nov 27, 2018

@shuLhan,

Thank you, that looks like a better solution than adding more complicated re.

@gopherbot

This comment has been minimized.

Copy link

commented Feb 1, 2019

Change https://golang.org/cl/160799 mentions this issue: [release-branch.go1.11] runtime: fix runtime gdb test with gdb v8.2

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