golang/go

unexpected fault address 0xb01dfacedebac1e

Closed this issue · 11 comments

What version of Go are you using (go version)?
go version go1.6 darwin/amd64

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

GOARCH="amd64"
GOBIN="/Users/aleksi/Code/My/0xb01dfacedebac1e/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/aleksi/Code/My/0xb01dfacedebac1e"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.6/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.6/libexec/pkg/tool/darwin_amd64"
GO15VENDOREXPERIMENT="1"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"

What did you do?
https://github.com/AlekSi/0xb01dfacedebac1e

What did you expect to see?
Test fails "normally".

What did you see instead?

=== RUN   TestCrash
unexpected fault address 0xb01dfacedebac1e
fatal error: fault
[signal 0xb code=0x1 addr=0xb01dfacedebac1e pc=0xe081f]

goroutine 5 [running]:
runtime.throw(0x40e958, 0x5)
    /usr/local/Cellar/go/1.6/libexec/src/runtime/panic.go:530 +0x90 fp=0xc82004cd18 sp=0xc82004cd00
runtime.sigpanic()
    /usr/local/Cellar/go/1.6/libexec/src/runtime/sigpanic_unix.go:27 +0x2ba fp=0xc82004cd68 sp=0xc82004cd18
unicode/utf8.DecodeRuneInString(0x35393538203a4449, 0x3237323439303133, 0x410280, 0x6)
    /usr/local/Cellar/go/1.6/libexec/src/unicode/utf8/utf8.go:206 +0x3f fp=0xc82004cd70 sp=0xc82004cd68
strconv.CanBackquote(0x35393538203a4449, 0x3237323439303133, 0x3237323439303133)
    /usr/local/Cellar/go/1.6/libexec/src/strconv/quote.go:177 +0x43 fp=0xc82004cd98 sp=0xc82004cd70
fmt.(*fmt).fmt_q(0xc820060e28, 0x35393538203a4449, 0x3237323439303133)
    /usr/local/Cellar/go/1.6/libexec/src/fmt/format.go:372 +0x8b fp=0xc82004ce18 sp=0xc82004cd98
fmt.(*pp).fmtString(0xc820060dd0, 0x35393538203a4449, 0x3237323439303133, 0xc800000071)
    /usr/local/Cellar/go/1.6/libexec/src/fmt/print.go:527 +0x9e fp=0xc82004ce48 sp=0xc82004ce18
fmt.(*pp).printArg(0xc820060dd0, 0x2fefc0, 0xc820011430, 0x71, 0x0, 0x0)
    /usr/local/Cellar/go/1.6/libexec/src/fmt/print.go:797 +0xd95 fp=0xc82004cfd0 sp=0xc82004ce48
fmt.(*pp).doPrintf(0xc820060dd0, 0x40be08, 0x3, 0xc82004d420, 0x1, 0x1)
    /usr/local/Cellar/go/1.6/libexec/src/fmt/print.go:1238 +0x1dcd fp=0xc82004d358 sp=0xc82004cfd0
fmt.Sprintf(0x40be08, 0x3, 0xc82004d420, 0x1, 0x1, 0x0, 0x0)
    /usr/local/Cellar/go/1.6/libexec/src/fmt/print.go:203 +0x6f fp=0xc82004d3a8 sp=0xc82004d358
github.com/AlekSi/0xb01dfacedebac1e.Inspect(0x2fefc0, 0xc820011420, 0xc820011400, 0x0, 0x0)
    /Users/aleksi/Code/My/0xb01dfacedebac1e/src/github.com/AlekSi/0xb01dfacedebac1e/inspect.go:11 +0x3e3 fp=0xc82004d4b0 sp=0xc82004d3a8
github.com/AlekSi/0xb01dfacedebac1e.Inspect(0x2e8540, 0xc8200ba980, 0x1, 0x0, 0x0)
    /Users/aleksi/Code/My/0xb01dfacedebac1e/src/github.com/AlekSi/0xb01dfacedebac1e/inspect.go:17 +0x278 fp=0xc82004d5b8 sp=0xc82004d4b0
github.com/AlekSi/0xb01dfacedebac1e.Person.String(0xc8200ba900, 0x99, 0x0, 0xc8200ba980, 0x0, 0x0)
    /Users/aleksi/Code/My/0xb01dfacedebac1e/src/github.com/AlekSi/0xb01dfacedebac1e/person.go:17 +0x23e fp=0xc82004d670 sp=0xc82004d5b8
github.com/AlekSi/0xb01dfacedebac1e.(*Person).String(0xc8200ba948, 0x0, 0x0)
    <autogenerated>:1 +0xa2 fp=0xc82004d6a8 sp=0xc82004d670
github.com/AlekSi/0xb01dfacedebac1e/vendor/github.com/stretchr/testify/vendor/github.com/davecgh/go-spew/spew.handleMethods(0x5ef8c0, 0x1214920, 0xc820056af0, 0x37b220, 0xc8200ba948, 0x16, 0x0)
    /Users/aleksi/Code/My/0xb01dfacedebac1e/src/github.com/AlekSi/0xb01dfacedebac1e/vendor/github.com/stretchr/testify/vendor/github.com/davecgh/go-spew/spew/common.go:137 +0x6e8 fp=0xc82004d780 sp=0xc82004d6a8
github.com/AlekSi/0xb01dfacedebac1e/vendor/github.com/stretchr/testify/vendor/github.com/davecgh/go-spew/spew.(*dumpState).dump(0xc82004dad0, 0x3bde80, 0xc8200ba900, 0x99)
    /Users/aleksi/Code/My/0xb01dfacedebac1e/src/github.com/AlekSi/0xb01dfacedebac1e/vendor/github.com/stretchr/testify/vendor/github.com/davecgh/go-spew/spew/dump.go:308 +0x496 fp=0xc82004da20 sp=0xc82004d780
github.com/AlekSi/0xb01dfacedebac1e/vendor/github.com/stretchr/testify/vendor/github.com/davecgh/go-spew/spew.fdump(0x5ef8c0, 0x1214920, 0xc820056af0, 0xc82004dc78, 0x1, 0x1)
    /Users/aleksi/Code/My/0xb01dfacedebac1e/src/github.com/AlekSi/0xb01dfacedebac1e/vendor/github.com/stretchr/testify/vendor/github.com/davecgh/go-spew/spew/dump.go:467 +0x2dc fp=0xc82004db08 sp=0xc82004da20
github.com/AlekSi/0xb01dfacedebac1e/vendor/github.com/stretchr/testify/vendor/github.com/davecgh/go-spew/spew.Sdump(0xc82004dc78, 0x1, 0x1, 0x0, 0x0)
    /Users/aleksi/Code/My/0xb01dfacedebac1e/src/github.com/AlekSi/0xb01dfacedebac1e/vendor/github.com/stretchr/testify/vendor/github.com/davecgh/go-spew/spew/dump.go:482 +0xaa fp=0xc82004db88 sp=0xc82004db08
github.com/AlekSi/0xb01dfacedebac1e/vendor/github.com/stretchr/testify/assert.diff(0x3bde80, 0xc8200ba900, 0x3bde80, 0xc8200ba920, 0x0, 0x0)
    /Users/aleksi/Code/My/0xb01dfacedebac1e/src/github.com/AlekSi/0xb01dfacedebac1e/vendor/github.com/stretchr/testify/assert/assertions.go:990 +0x1de fp=0xc82004dd80 sp=0xc82004db88
github.com/AlekSi/0xb01dfacedebac1e/vendor/github.com/stretchr/testify/assert.Equal(0x12148f8, 0xc820080090, 0x3bde80, 0xc8200ba900, 0x3bde80, 0xc8200ba920, 0x0, 0x0, 0x0, 0x0)
    /Users/aleksi/Code/My/0xb01dfacedebac1e/src/github.com/AlekSi/0xb01dfacedebac1e/vendor/github.com/stretchr/testify/assert/assertions.go:264 +0x9d fp=0xc82004de50 sp=0xc82004dd80
github.com/AlekSi/0xb01dfacedebac1e.TestCrash(0xc820080090)
    /Users/aleksi/Code/My/0xb01dfacedebac1e/src/github.com/AlekSi/0xb01dfacedebac1e/person_test.go:13 +0x1e0 fp=0xc82004df58 sp=0xc82004de50
testing.tRunner(0xc820080090, 0x5eedf0)
    /usr/local/Cellar/go/1.6/libexec/src/testing/testing.go:473 +0x98 fp=0xc82004df90 sp=0xc82004df58
runtime.goexit()
    /usr/local/Cellar/go/1.6/libexec/src/runtime/asm_amd64.s:1998 +0x1 fp=0xc82004df98 sp=0xc82004df90
created by testing.RunTests
    /usr/local/Cellar/go/1.6/libexec/src/testing/testing.go:582 +0x892

goroutine 1 [chan receive]:
testing.RunTests(0x4b7280, 0x5eedf0, 0x1, 0x1, 0x5f7a01)
    /usr/local/Cellar/go/1.6/libexec/src/testing/testing.go:583 +0x8d2
testing.(*M).Run(0xc82004bef8, 0x0)
    /usr/local/Cellar/go/1.6/libexec/src/testing/testing.go:515 +0x81
main.main()
    github.com/AlekSi/0xb01dfacedebac1e/_test/_testmain.go:54 +0x117

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
    /usr/local/Cellar/go/1.6/libexec/src/runtime/asm_amd64.s:1998 +0x1
exit status 2
FAIL    github.com/AlekSi/0xb01dfacedebac1e 0.013s

I found this reference for 0xb01dfacedebac1e: https://golang.org/src/runtime/signal_amd64x.go#L53

This crash is originated in seemingly minor change in a large codebase. I spent a couple of hours trimming it down, removing database access, networking, etc. Unfortunately, I wasn't able to make it smaller: every change, even small logging statement seems to "fix" the issue.

It works with Go 1.5.3 on the same Mac.

Paging Mr. Signals, @ianlancetaylor

minux commented

I get something different on OS X at tip:

ward5k:0xb01dfacedebac1e bradfitz$ go version
go version devel +ca56c59 Thu Mar 3 22:28:00 2016 +0000 darwin/amd64
ward5k:0xb01dfacedebac1e bradfitz$ go test -v 
=== RUN   TestCrash
fatal error: bad pointer in write barrier

runtime stack:
runtime.throw(0x3b6d2d, 0x1c)
    /Users/bradfitz/go/src/runtime/panic.go:549 +0x8c
runtime.writebarrierptr_nostore.func1()
    /Users/bradfitz/go/src/runtime/mbarrier.go:157 +0x2c
runtime.systemstack(0xc82001e000)
    /Users/bradfitz/go/src/runtime/asm_amd64.s:291 +0x79
runtime.mstart()
    /Users/bradfitz/go/src/runtime/proc.go:1030

goroutine 20 [running]:
runtime.systemstack_switch()
    /Users/bradfitz/go/src/runtime/asm_amd64.s:245 fp=0xc820047880 sp=0xc820047878
runtime.writebarrierptr_nostore(0xc8204dc070, 0x99)
    /Users/bradfitz/go/src/runtime/mbarrier.go:157 +0x3e fp=0xc820047898 sp=0xc820047880
runtime.heapBitsBulkBarrier(0xc8204dc070, 0x10)
    /Users/bradfitz/go/src/runtime/mbitmap.go:439 +0x140 fp=0xc8200478e0 sp=0xc820047898
runtime.typedmemmove(0x29ff80, 0xc8204dc070, 0xc8200479a8)
    /Users/bradfitz/go/src/runtime/mbarrier.go:197 +0x5a fp=0xc820047910 sp=0xc8200478e0
runtime.convT2E(0x29ff80, 0xc8200479a8, 0xc8204dc070, 0x0, 0x0)
    /Users/bradfitz/go/src/runtime/iface.go:144 +0x62 fp=0xc820047930 sp=0xc820047910
github.com/AlekSi/0xb01dfacedebac1e.Person.String(0xc8200dc740, 0x99, 0x0, 0xc82007c200, 0xc8200479d8, 0xc8200479e8)
    /Users/bradfitz/src/github.com/AlekSi/0xb01dfacedebac1e/person.go:16 +0xdf fp=0xc8200479a0 sp=0xc820047930
github.com/AlekSi/0xb01dfacedebac1e.(*Person).String(0xc82007c1c8, 0x40fb98, 0x6b38f8)
    <autogenerated>:1 +0x63 fp=0xc8200479d8 sp=0xc8200479a0
github.com/AlekSi/0xb01dfacedebac1e/vendor/github.com/stretchr/testify/vendor/github.com/davecgh/go-spew/spew.handleMethods(0x559680, 0x6b38f8, 0xc82006a070, 0x35c9c0, 0xc8200dc740, 0x99, 0x0)
    /Users/bradfitz/src/github.com/AlekSi/0xb01dfacedebac1e/vendor/github.com/stretchr/testify/vendor/github.com/davecgh/go-spew/spew/common.go:137 +0x57a fp=0xc820047a60 sp=0xc8200479d8
github.com/AlekSi/0xb01dfacedebac1e/vendor/github.com/stretchr/testify/vendor/github.com/davecgh/go-spew/spew.(*dumpState).dump(0xc820047c38, 0x35c9c0, 0xc8200dc740, 0x99)
    /Users/bradfitz/src/github.com/AlekSi/0xb01dfacedebac1e/vendor/github.com/stretchr/testify/vendor/github.com/davecgh/go-spew/spew/dump.go:308 +0x152d fp=0xc820047be0 sp=0xc820047a60
github.com/AlekSi/0xb01dfacedebac1e/vendor/github.com/stretchr/testify/vendor/github.com/davecgh/go-spew/spew.fdump(0x559680, 0x6b38f8, 0xc82006a070, 0xc820047d88, 0x1, 0x1)
    /Users/bradfitz/src/github.com/AlekSi/0xb01dfacedebac1e/vendor/github.com/stretchr/testify/vendor/github.com/davecgh/go-spew/spew/dump.go:467 +0x120 fp=0xc820047c70 sp=0xc820047be0
github.com/AlekSi/0xb01dfacedebac1e/vendor/github.com/stretchr/testify/vendor/github.com/davecgh/go-spew/spew.Sdump(0xc820047d88, 0x1, 0x1, 0xc821c3e000, 0x7c249e)
    /Users/bradfitz/src/github.com/AlekSi/0xb01dfacedebac1e/vendor/github.com/stretchr/testify/vendor/github.com/davecgh/go-spew/spew/dump.go:482 +0x88 fp=0xc820047cb0 sp=0xc820047c70
github.com/AlekSi/0xb01dfacedebac1e/vendor/github.com/stretchr/testify/assert.diff(0x35c9c0, 0xc8200dc720, 0x35c9c0, 0xc8200dc740, 0x0, 0x3a90d0)
    /Users/bradfitz/src/github.com/AlekSi/0xb01dfacedebac1e/vendor/github.com/stretchr/testify/assert/assertions.go:991 +0x22e fp=0xc820047e38 sp=0xc820047cb0
github.com/AlekSi/0xb01dfacedebac1e/vendor/github.com/stretchr/testify/assert.Equal(0x6b38d0, 0xc8200a2120, 0x35c9c0, 0xc8200dc720, 0x35c9c0, 0xc8200dc740, 0x0, 0x0, 0x0, 0x0)
    /Users/bradfitz/src/github.com/AlekSi/0xb01dfacedebac1e/vendor/github.com/stretchr/testify/assert/assertions.go:264 +0x97 fp=0xc820047ec0 sp=0xc820047e38
github.com/AlekSi/0xb01dfacedebac1e.TestCrash(0xc8200a2120)
    /Users/bradfitz/src/github.com/AlekSi/0xb01dfacedebac1e/person_test.go:13 +0x16b fp=0xc820047f70 sp=0xc820047ec0
testing.tRunner(0xc8200a2120, 0x558bb0)
    /Users/bradfitz/go/src/testing/testing.go:473 +0x7e fp=0xc820047f90 sp=0xc820047f70
runtime.goexit()
    /Users/bradfitz/go/src/runtime/asm_amd64.s:2006 +0x1 fp=0xc820047f98 sp=0xc820047f90
created by testing.RunTests
    /Users/bradfitz/go/src/testing/testing.go:581 +0x313

goroutine 1 [chan receive]:
testing.RunTests(0x40fbd0, 0x558bb0, 0x1, 0x1, 0x320c01)
    /Users/bradfitz/go/src/testing/testing.go:582 +0x359
testing.(*M).Run(0xc82003df08, 0x5bca)
    /Users/bradfitz/go/src/testing/testing.go:515 +0x79
main.main()
    github.com/AlekSi/0xb01dfacedebac1e/_test/_testmain.go:54 +0xb4

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
    /Users/bradfitz/go/src/runtime/asm_amd64.s:2006 +0x1
exit status 2
FAIL    github.com/AlekSi/0xb01dfacedebac1e 0.073s

(And no difference if I use -race)

I believe the source of the problem is the vendored copy of https://github.com/davecgh/go-spew. It uses unsafe for some "advanced features". Recompilation with -tags disableunsafe fixed the issue.

I wonder if something can/should be done in Go, or this issue can be closed?

Oh, god, don't read spew/bypass.go. It made my eyes bleed.
It knows more about the internals of reflect.Value than the reflect package does.

Okay, closing. I think we should make runtime crashes contain a warning at top saying "Warning: unsafe" if any untrusted unsafe code was linked in.

RLH commented

0xb01dfacedebac1e is a poison pointer cleverly designed so that if
0xb01dfacedebac1e is Googled one will get RSC's original CL. It is
probably the result of unsafe pointer abuse.

On Thu, Mar 3, 2016 at 7:34 PM, Brad Fitzpatrick notifications@github.com
wrote:

Closed #14631 #14631.


Reply to this email directly or view it on GitHub
#14631 (comment).

What about a "Warning: outdated version of a package was used, do so at your own risk" message...

I feel bad because Dave Collins (@davecgh) worked hard to catch and fix that problem on Nov 5, 2015, which was days within the reflect change landing in tip, and well in advance of the next Go release that contained the breaking internal reflect changes. But his efforts were compromised by vendoring an outdated version for nearly a year.

@shurcooL when would this warning be printed, which part of the toolchain or runtime should be responsible for printing it ?

I didn't mean that literally. I just wanted to express my frustration with vendoring outdated dependencies that have bugs that have since been fixed in the current release, which is what caused this issue.

I just wanted to express my frustration with vendoring outdated dependencies that have bugs

Vendoring also allows one to vendor outdated dependencies that have no bugs and compatibility problems, unlike current versions. That's the whole point of vendoring.

I'm sure there are several tools to check and update vendored dependencies, one example is https://github.com/divan/gofresh. It's not runtime's responsibility.

And it's also not the right place to continue this discussion. :) Sorry.

For the record: github.com/stretchr/testify is fixed now.