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: program terminated with signal 7, bus error #32446

Closed
beibeiabeibei opened this issue Jun 5, 2019 · 7 comments
Closed

runtime: program terminated with signal 7, bus error #32446

beibeiabeibei opened this issue Jun 5, 2019 · 7 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@beibeiabeibei
Copy link

beibeiabeibei commented Jun 5, 2019

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

$ go version
go version go1.11.1 linux/amd64

Does this issue reproduce with the latest release?

I am not sure

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/gamedev/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/opt/applications/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/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-build002037776=/tmp/go-build -gno-record-gcc-switches"

What did you do?

server.go

func main() {
        forever := make(chan bool)
        go tokenManager.TimerFreshToken()
        <-forever
}

freshtoken.go

func TimerFreshToken() {
        timer := time.NewTicker(time.Second)
        for {
                select {
                case now := <-timer.C:
                        timestamp := now.Unix()
                        if timestamp%int64(comData.TOKEN_REFRESH_GAP) == 0 {
                                BatchFresh()
                                BatchFreshAuthorizerToken()
                                BatchFreshMinigameToken()
                        }
                        if timestamp%int64(comData.TOKEN_PING_GAP) == 0 {
                                PingComponentToken()
                                PingAuthorizerToken()
                                PingMinigameToken()
                        }
                }
        }
}

Frequency of occurrence

Once a week to three weeks. And the program runs in K8S

What did you see instead?

sometimes the system generated the coredump file,use gdb show:

Program terminated with signal 7, Bus error.
#0  runtime.sigtrampgo (ctx=<optimized out>, info=<optimized out>, sig=<optimized out>) at /usr/local/go/src/runtime/signal_unix.go:288
(gdb) bt
#0  runtime.sigtrampgo (ctx=<optimized out>, info=<optimized out>, sig=<optimized out>) at /usr/local/go/src/runtime/signal_unix.go:288
#1  0x000000000045a5d3 in runtime.sigtramp () at /usr/local/go/src/runtime/sys_linux_amd64.s:353
#2  <signal handler called>
#3  0x00000000004070f0 in runtime.sendDirect (sg=<optimized out>, src=<optimized out>, t=<optimized out>) at /usr/local/go/src/runtime/chan.go:312
#4  0x000000000040707e in runtime.send (c=0xc00019d6e0, ep=0xc00015a730, sg=0xc0000ccae0, skip=3, unlockf={void ()} 0xc00015a678) at /usr/local/go/src/runtime/chan.go:283
#5  0x0000000000406e8f in runtime.chansend (block=false, c=0xc00019d6e0, callerpc=<optimized out>, ep=0xc00015a730, ~r4=<optimized out>) at /usr/local/go/src/runtime/chan.go:191
#6  0x0000000000407d64 in runtime.selectnbsend (c=<optimized out>, elem=<optimized out>, selected=<optimized out>) at /usr/local/go/src/runtime/chan.go:611
#7  0x0000000000482ecc in time.sendTime (c=..., seq=<optimized out>) at /usr/local/go/src/time/sleep.go:141
#8  0x0000000000449dd1 in runtime.timerproc (tb=<optimized out>) at /usr/local/go/src/runtime/time.go:274
#9  0x00000000004589e1 in runtime.goexit () at /usr/local/go/src/runtime/asm_amd64.s:1333
#10 0x0000000000d08020 in runtime.timers ()
#11 0x0000000000000000 in ?? ()

sometimes it threw error message :

unexpected fault address 0xcc20ce
fatal error: fault
[signal SIGBUS: bus error code=0x2 addr=0xcc20ce pc=0x4033be]
goroutine 36 [running]:
fatal error: unexpected signal during runtime execution
panic during panic
[signal SIGBUS: bus error code=0x2 addr=0x9f2fac pc=0x44c957]
runtime stack:
fatal error: unexpected signal during runtime execution
stack trace unavailable
@agnivade
Copy link
Contributor

agnivade commented Jun 5, 2019

@ianlancetaylor ianlancetaylor changed the title Program terminated with signal 7, Bus error. runtime: program terminated with signal 7, bus error Jun 5, 2019
@ianlancetaylor ianlancetaylor added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 5, 2019
@ianlancetaylor ianlancetaylor added this to the Go1.13 milestone Jun 5, 2019
@ianlancetaylor
Copy link
Contributor

Looks like memory corruption. Is there any cgo or unsafe code in your program? Is there a way that we can run your program ourselves to try to reproduce the problem? Does this happen on more than one physical machine?

@ianlancetaylor
Copy link
Contributor

Also, how hard would it be for you try the 1.12.5 release?

@agnivade agnivade added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jun 6, 2019
@beibeiabeibei
Copy link
Author

beibeiabeibei commented Jun 10, 2019

Looks like memory corruption. Is there any cgo or unsafe code in your program? Is there a way that we can run your program ourselves to try to reproduce the problem? Does this happen on more than one physical machine?

I don't use cgo or unsafe package in my program.
And it threw a more detailed error yesterday , I think the error caused by Log printing.

unexpected fault address 0x67f8e0
fatal error: fault
[signal SIGBUS: bus error code=0x2 addr=0x67f8e0 pc=0x67f8e0]

goroutine 83 [running]:
runtime.throw(0x9096e7, 0x5)
        /usr/local/go/src/runtime/panic.go:608 +0x72 fp=0xc000505b98 sp=0xc000505b68 pc=0x42c5a2
runtime.sigpanic()
        /usr/local/go/src/runtime/signal_unix.go:387 +0x2d7 fp=0xc000505be8 sp=0xc000505b98 pc=0x441127
github.com/cihub/seelog.(*rollTimeFileTailsSlice).Len(0xc000551b60, 0xc000551b60)
        <autogenerated>:1 fp=0xc000505bf0 sp=0xc000505be8 pc=0x67f8e0
sort.Sort(0x987f80, 0xc000551b60)
        /usr/local/go/src/sort/sort.go:217 +0x31 fp=0xc000505c30 sp=0xc000505bf0 pc=0x55ce31
github.com/cihub/seelog.(*rollingFileWriterTime).sortFileRollNamesAsc(0xc0001f5440, 0xc0003b0400, 0x1e, 0x20, 0x1, 0xc000505d68, 0xa, 0x20, 0x0)
        /opt/applications/go/pkg/mod/github.com/cihub/seelog@v0.0.0-20180626064034-ea380b2c6fc6/writers_rollingfilewriter.go:739 +0xc8 fp=0xc000505cb0 sp=0xc000505c30 pc=0x678878
github.com/cihub/seelog.(*rollingFileWriter).getSortedLogHistory(0xc000274000, 0x0, 0x0, 0xa, 0xc000505e40, 0xa)
        /opt/applications/go/pkg/mod/github.com/cihub/seelog@v0.0.0-20180626064034-ea380b2c6fc6/writers_rollingfilewriter.go:297 +0x129 fp=0xc000505e08 sp=0xc000505cb0 pc=0x675949
github.com/cihub/seelog.(*rollingFileWriter).roll(0xc000274000, 0x926001, 0xc000274080)
        /opt/applications/go/pkg/mod/github.com/cihub/seelog@v0.0.0-20180626064034-ea380b2c6fc6/writers_rollingfilewriter.go:523 +0x7d fp=0xc000505ed8 sp=0xc000505e08 pc=0x6771fd
github.com/cihub/seelog.(*rollingFileWriter).Write(0xc000274000, 0xc000276000, 0x38d, 0x2710, 0x0, 0x0, 0x0)
        /opt/applications/go/pkg/mod/github.com/cihub/seelog@v0.0.0-20180626064034-ea380b2c6fc6/writers_rollingfilewriter.go:561 +0x172 fp=0xc000505f28 sp=0xc000505ed8 pc=0x677752
bufio.(*Writer).Flush(0xc000206bc0, 0x926088, 0xc000212350)
        /usr/local/go/src/bufio/bufio.go:575 +0x75 fp=0xc000505f88 sp=0xc000505f28 pc=0x4cff55
github.com/cihub/seelog.(*bufferedWriter).flushBuffer(0xc0001f5470)
        /opt/applications/go/pkg/mod/github.com/cihub/seelog@v0.0.0-20180626064034-ea380b2c6fc6/writers_bufferedwriter.go:146 +0x6b fp=0xc000505fb0 sp=0xc000505f88 pc=0x67432b
github.com/cihub/seelog.(*bufferedWriter).flushPeriodically(0xc0001f5470)
        /opt/applications/go/pkg/mod/github.com/cihub/seelog@v0.0.0-20180626064034-ea380b2c6fc6/writers_bufferedwriter.go:154 +0x60 fp=0xc000505fd8 sp=0xc000505fb0 pc=0x6743c0
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1333 +0x1 fp=0xc000505fe0 sp=0xc000505fd8 pc=0x4589e1
created by github.com/cihub/seelog.NewBufferedWriter
        /opt/applications/go/pkg/mod/github.com/cihub/seelog@v0.0.0-20180626064034-ea380b2c6fc6/writers_bufferedwriter.go:76 +0x16c

Find the code

type rollSizeFileTailsSlice []string

func (p rollSizeFileTailsSlice) Len() int {
        return len(p)                             //there
}
func (rws *rollingFileWriterSize) sortFileRollNamesAsc(fs []string) ([]string, error) {
        ss := rollSizeFileTailsSlice(fs)
        sort.Sort(ss)                    //
        return ss, nil
}
//sort.Sort 
func Sort(data Interface) {
        n := data.Len()                    //cored by there
        quickSort(data, 0, n, maxDepth(n))
}

I do not why it cause bus error. even if the parameter of fs is nil, it should cause segmentation fault.

@agnivade
Copy link
Contributor

Hi @beibeiabeibei - It is possible that there is a race somewhere. Although, why does it give SIGBUS, I am not sure. Please build and run your program with the -race flag just to ensure there are no race conditions.

Also, please give us a complete code sample along with steps so that we can reproduce the issue ourselves. It is not possible for us to find the issue ourselves by just looking at a snippet.

Lastly, as mentioned earlier, have you tried with the 1.12.5 release and faced the same crashes ?

@agnivade agnivade added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Jun 10, 2019
@beibeiabeibei
Copy link
Author

beibeiabeibei commented Jun 10, 2019

Hi @beibeiabeibei - It is possible that there is a race somewhere. Although, why does it give SIGBUS, I am not sure. Please build and run your program with the -race flag just to ensure there are no race conditions.
Thank you very much ,I will use -race flag to test。I need a long time to recreate the problem
Also, please give us a complete code sample along with steps so that we can reproduce the issue ourselves. It is not possible for us to find the issue ourselves by just looking at a snippet.
sorry , the code is hard to disparate from the project. I try to find the important part,but failed.

@andybons andybons modified the milestones: Go1.13, Go1.14 Jul 8, 2019
@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
@ALTree
Copy link
Member

ALTree commented Jun 18, 2021

This has been in waiting for info for a couple years with no reproducer, so let's archive this.

@ALTree ALTree closed this as completed Jun 18, 2021
@golang golang locked and limited conversation to collaborators Jun 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

7 participants