FAQ
Hi,

I'm having trouble with a weird bug, I don't know if this is caused by me
or by a buggy Go runtime/compiler.
It happens only sometimes and in special app circumstances.

The error log is:

unexpected fault address 0x7f701d1529e7
fatal error: fault
[signal 0xb code=0x1 addr=0x7f701d1529e7 pc=0x45c6d1]

goroutine 50 [running]:
runtime.throw(0x5f1fd8, 0x5)
         /usr/lib/go/src/runtime/panic.go:527 +0x90 fp=0xc8211b6c40
sp=0xc8211b6c28
runtime.sigpanic()
         /usr/lib/go/src/runtime/sigpanic_unix.go:27 +0x2ab fp=0xc8211b6c90
sp=0xc8211b6c40
runtime.memmove(0xc82115880d, 0x7f701d1529e7, 0x2)
         /usr/lib/go/src/runtime/memmove_amd64.s:122 +0x1f1 fp=0xc8211b6c98
sp=0xc8211b6c90
treeless/src/com/tcp.(*Message).write(0xc8211de100, 0xc821158800, 0x800,
0x800, 0x501, 0x0)
         /home/dv/Programacion/go/src/treeless/src/com/tcp/tcpcom.go:60
+0x6d6 fp=0xc8211b6e20 sp=0xc8211b6c98
...


My app line tcpcom.go:60 only do this:

     copy(dest[13:], m.Key)


And m is of type:

type Message struct {

     Type Operation

     ID uint32

     Key, Value []byte

}


m is retrieved from a channel:

         case m, ok := <-msgChannel:

             if !ok {

                 //Channel closed, stop loop

                 timer.Stop()

                 return

             }

             ...


The channel is declared this way:

       msgChannel chan Message


My code uses multiple goroutines with a high value of threads (GOMAXPROCS). However, I executed it with the race detector and the problem shows up again without detecting any race condition.


I tried setting GOMAXPROCS to 1 and it still happens, however, I think it happens less times now.


I cannot be 100% sure but I think dest has between 300 and 1300 allocated bytes and m.Key is nil.


I'm really surprised of this behavior, this line is executed thousands of times in my code, but only sometimes and in a particular moment of the app logic the bug shows up.


I assigned []byte(" ") to m.Key and it doesn't solve the problem.


My go version is:

go version go1.5.3 linux/amd64


Do you have any clues? Is this my fault? Is this Go fault?

Edit: after several changes I've seen a different, yet similar traceback
(now it points to memmove_amd64.s:130):
unexpected fault address 0x7f1dd6f9fc1a
fatal error: fault
[signal 0xb code=0x1 addr=0x7f1dd6f9fc1a pc=0x45c859]

goroutine 41 [running]:
runtime.throw(0x5f1fd8, 0x5)
         /usr/lib/go/src/runtime/panic.go:527 +0x90 fp=0xc821114500
sp=0xc8211144e8
runtime.sigpanic()
         /usr/lib/go/src/runtime/sigpanic_unix.go:27 +0x2ab fp=0xc821114550
sp=0xc821114500
runtime.memmove(0xc8211e03cb, 0x7f1dd6f9fc1a, 0x3)
         /usr/lib/go/src/runtime/memmove_amd64.s:130 +0x379 fp=0xc821114558
sp=0xc821114550
treeless/src/com/tcp.(*Message).write(0xc8211f4400, 0xc8211e03be, 0x34a,
0x34a, 0x0, 0x0)
         /home/dv/Programacion/go/src/treeless/src/com/tcp/tcpcom.go:64
+0x360 fp=0xc821114630 sp=0xc821114558


Thanks,
David

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Dave Cheney at Jan 26, 2016 at 12:20 am
    The first step in diagnosing this kind of problem is to check your program for data race. You can use the race detector to run your tests, go test -race, or, if the problem only appears when your program is exposed to love traffic, you can build a race enabled version of your program with go build -race.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Manxi David at Jan 26, 2016 at 12:35 am
    Hi,

    I've already used it as I said, the bug persists and it didnt found any race conditions.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Dave Cheney at Jan 26, 2016 at 12:41 am
    The second thing to check is cgo. Does your application use cgo to bind to an external library?

    If so, could you try one of the recent 1.6 betas which includes checks for incorrect sharing of data between Go and C.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Manxi David at Jan 26, 2016 at 12:59 am
    It doesn't, the only external library is https://godoc.org/launchpad.net/gommap
    I know that I have to be extremely careful with these memory-mapped files, but the error is very far away of this, and all memory in the affected file is typical (go-allocated).

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Dave Cheney at Jan 26, 2016 at 1:06 am
    Go includes mmap support in the syscall package. Can you use that and
    eliminate this external package ?
    On Tuesday, 26 January 2016 11:59:25 UTC+11, manxi...@gmail.com wrote:

    It doesn't, the only external library is
    https://godoc.org/launchpad.net/gommap
    I know that I have to be extremely careful with these memory-mapped files,
    but the error is very far away of this, and all memory in the affected file
    is typical (go-allocated).
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Manxi David at Jan 26, 2016 at 1:17 am
    I think this package already uses the syscall package: http://bazaar.launchpad.net/+branch/gommap/view/head:/gommap.go#L124

    Moreover, I dont think this is gommap fault.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • David M. at Jan 26, 2016 at 8:54 pm
    Hi,

    It was all my fault, I misused the memory mapped file, that's why the error
    was so strange.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJan 25, '16 at 11:55p
activeJan 26, '16 at 8:54p
posts8
users2
websitegolang.org

2 users in discussion

David M.: 5 posts Dave Cheney: 3 posts

People

Translate

site design / logo © 2022 Grokbase