FAQ
I'm getting "panic: fatal error: malloc deadlock" quite reproducibly in
my program: https://github.com/ncw/go-nflog-acctd when compiled with go
1.6 and run with cpu profiling.

The code runs clean with the race detector enabled.

The panic only seems to happen when cpu profiling is enabled so I'd
guess it is something to do with that.

The stack trace looks like this

--------------------------------------
panic: fatal error: malloc deadlock

goroutine 0 [idle]:
panic(0x58a9a0, 0xc8200100d0)
  /usr/local/go/src/runtime/panic.go:355 +0x7a

goroutine 8 [syscall, locked to thread]:
runtime.cgocall(0x536610, 0xc8200f9ea0, 0x0)
  /usr/local/go/src/runtime/cgocall.go:123 +0x11b fp=0xc8200f9e50
sp=0xc8200f9e20
main._Cfunc_nflog_handle_packet(0x222db50, 0x7f1d000008c0, 0x1dc4, 0x0)
  ??:0 +0x41 fp=0xc8200f9ea0 sp=0xc8200f9e50
main.(*NfLog).Loop(0xc820016140)
  /home/ncw/Code/Go/src/github.com/ncw/go-nflog-acctd/nflog.go:357 +0x386
fp=0xc8200f9fa8 sp=0xc8200f9ea0
runtime.goexit()
  /usr/local/go/src/runtime/asm_amd64.s:1998 +0x1 fp=0xc8200f9fb0
sp=0xc8200f9fa8
created by main.NewNfLog
  /home/ncw/Code/Go/src/github.com/ncw/go-nflog-acctd/nflog.go:192 +0x501

goroutine 1 [chan receive]:
main.main()
  /home/ncw/Code/Go/src/github.com/ncw/go-nflog-acctd/main.go:399 +0xf1a

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
  /usr/local/go/src/runtime/asm_amd64.s:1998 +0x1

goroutine 5 [syscall]:
os/signal.signal_recv(0x0)
  /usr/local/go/src/runtime/sigqueue.go:116 +0x132
os/signal.loop()
  /usr/local/go/src/os/signal/signal_unix.go:22 +0x18
created by os/signal.init.1
  /usr/local/go/src/os/signal/signal_unix.go:28 +0x37

goroutine 6 [syscall]:
runtime.CPUProfile(0x0, 0x0, 0x0)
  /usr/local/go/src/runtime/cpuprof.go:421 +0x34
runtime/pprof.profileWriter(0x7f1d21ddb308, 0xc820028030)
  /usr/local/go/src/runtime/pprof/pprof.go:607 +0x1c
created by runtime/pprof.StartCPUProfile
  /usr/local/go/src/runtime/pprof/pprof.go:601 +0x145

goroutine 7 [runnable, locked to thread]:
main._C2func_recv(0x4, 0x7f1d080008c0, 0x400000, 0x0, 0x1144, 0x0, 0x0)
  ??:0 +0x56
main.(*NfLog).Loop(0xc8200160a0)
  /home/ncw/Code/Go/src/github.com/ncw/go-nflog-acctd/nflog.go:344 +0x202
created by main.NewNfLog
  /home/ncw/Code/Go/src/github.com/ncw/go-nflog-acctd/nflog.go:192 +0x501

goroutine 9 [syscall, locked to thread]:
main._C2func_recv(0x6, 0x7f1d1db54010, 0x400000, 0x0, 0x0, 0x0, 0x0)
  ??:0 +0x56
main.(*NfLog).Loop(0xc8200161e0)
  /home/ncw/Code/Go/src/github.com/ncw/go-nflog-acctd/nflog.go:344 +0x202
created by main.NewNfLog
  /home/ncw/Code/Go/src/github.com/ncw/go-nflog-acctd/nflog.go:192 +0x501

goroutine 10 [syscall, locked to thread]:
main._C2func_recv(0x7, 0x7f1d1c751010, 0x400000, 0x0, 0x0, 0x0, 0x0)
  ??:0 +0x56
main.(*NfLog).Loop(0xc820016280)
  /home/ncw/Code/Go/src/github.com/ncw/go-nflog-acctd/nflog.go:344 +0x202
created by main.NewNfLog
  /home/ncw/Code/Go/src/github.com/ncw/go-nflog-acctd/nflog.go:192 +0x501

goroutine 11 [runnable]:
main.(*Accounting).Engine(0xc82000a1b0)
  /home/ncw/Code/Go/src/github.com/ncw/go-nflog-acctd/main.go:190 +0x3fa
created by main.(*Accounting).Start
  /home/ncw/Code/Go/src/github.com/ncw/go-nflog-acctd/main.go:280 +0x8a

goroutine 12 [select]:
main.(*Accounting).DumpStats(0xc82000a1b0)
  /home/ncw/Code/Go/src/github.com/ncw/go-nflog-acctd/main.go:260 +0x6f1
created by main.(*Accounting).Start
  /home/ncw/Code/Go/src/github.com/ncw/go-nflog-acctd/main.go:282 +0xcf

goroutine 13 [select, locked to thread]:
runtime.gopark(0x60bf20, 0xc820021f28, 0x5c24d8, 0x6, 0x18, 0x2)
  /usr/local/go/src/runtime/proc.go:262 +0x163
runtime.selectgoImpl(0xc820021f28, 0x0, 0x18)
  /usr/local/go/src/runtime/select.go:392 +0xa67
runtime.selectgo(0xc820021f28)
  /usr/local/go/src/runtime/select.go:215 +0x12
runtime.ensureSigM.func1()
  /usr/local/go/src/runtime/signal1_unix.go:279 +0x358
runtime.goexit()
  /usr/local/go/src/runtime/asm_amd64.s:1998 +0x1
--------------------------------------

To reproduce on a Linux amd64 based system

sudo apt-get install libnetfilter-log-dev
go get github.com/ncw/go-nflog-acctd
cd $GOPATH/github.com/ncw/go-nflog-acctd
sudo start-iptables-accounting-nflog
sudo go-nflog-acctd -interval 10s -ip4-dst-group=4 -ip4-src-group=5
-ip6-dst-group=6 -ip6-src-group=7 -cpuprofile z.prof

In another window run

sudo sudo hping3 127.0.0.2 --syn -p 80 -s 53 --flood

This usually produces a stack trace within a minute or two.

I haven't made it go wrong without the `-cpuprofile z.prof` flag.

Any ideas?

Thanks

Nick
--
Nick Craig-Wood <nick@craig-wood.com> -- http://www.craig-wood.com/nick

--
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

  • Ian Lance Taylor at Mar 1, 2016 at 5:22 pm

    On Tue, Mar 1, 2016 at 8:58 AM, Nick Craig-Wood wrote:
    I'm getting "panic: fatal error: malloc deadlock" quite reproducibly in
    my program: https://github.com/ncw/go-nflog-acctd when compiled with go
    1.6 and run with cpu profiling.
    1. Please open an issue at https://golang.org/issue with these details.

    2. Please attach to the issue a traceback with GOTRACEBACK=all in the
    environment.

    Thanks.

    Ian

    --
    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.
  • Nick Craig-Wood at Mar 2, 2016 at 5:47 pm

    On 01/03/16 17:22, Ian Lance Taylor wrote:
    On Tue, Mar 1, 2016 at 8:58 AM, Nick Craig-Wood wrote:

    I'm getting "panic: fatal error: malloc deadlock" quite reproducibly in
    my program: https://github.com/ncw/go-nflog-acctd when compiled with go
    1.6 and run with cpu profiling.
    1. Please open an issue at https://golang.org/issue with these details.

    2. Please attach to the issue a traceback with GOTRACEBACK=all in the
    environment.
    I've stuck that at

    https://github.com/golang/go/issues/14599

    Thanks

    Nick
    --
    Nick Craig-Wood <nick@craig-wood.com> -- http://www.craig-wood.com/nick

    --
    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
postedMar 1, '16 at 4:58p
activeMar 2, '16 at 5:47p
posts3
users2
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase