On Tuesday, November 15, 2016 at 2:55:02 PM UTC-8, 李穗恒 wrote: > I cause panic when I use test in a function with > telegraf.Accumulator.AddFields > it looks like atomic.addUint64 cause the panic > How can I fit itvim-go: --- FAIL: TestPingGather (0.00s) > panic: runtime error: invalid memory address or nil pointer dereference > [recovered] > panic: runtime error: invalid memory address or nil pointer > dereference > [signal SIGSEGV: segmentation violation code=0x1 addr=0x4 pc=0xae220] > > goroutine 21 [running]: > panic(0x25f2f8, 0x10626008) > /usr/local/go/src/runtime/panic.go:500 +0x33c > testing.tRunner.func1(0x10666680) > /usr/local/go/src/testing/testing.go:579 +0x168 > panic(0x25f2f8, 0x10626008) > /usr/local/go/src/runtime/panic.go:458 +0x454 > sync/atomic.addUint64(0x1066c614, 0x1, 0x0, 0x1, 0x0) > /usr/local/go/src/sync/atomic/64bit_arm.go:31 +0x68 > github.com/influxdata/telegraf/testutil.(*Accumulator).AddFields(0x1066c600, > 0x28a96f, 0x5, 0x106692c0, 0x106692a0, 0x106b5c20, 0x1, 0x1) > > /workspace/go/src/github.com/influxdata/telegraf/testutil/accumulator.go:56 > +0x64 > github.com/influxdata/telegraf/plugins/inputs/dht.(*Dht).Gather(0x10632f98, > 0x35f010, 0x1066c600, 0x0, 0x0) > > /workspace/go/src/github.com/influxdata/telegraf/plugins/inputs/dht/dht.go:52 > +0x2fc > github.com/influxdata/telegraf/plugins/inputs/dht.TestPingGather(0x10666680) > > /workspace/go/src/github.com/influxdata/telegraf/plugins/inputs/dht/dht_test.go:20 > +0xb4 > testing.tRunner(0x10666680, 0x2b2e34) > /usr/local/go/src/testing/testing.go:610 +0xa4 > created by testing.(*T).Run > /usr/local/go/src/testing/testing.go:646 +0x304 > exit status 2 > FAIL github.com/influxdata/telegraf/plugins/inputs/dht 0.020s > vim-go: [test] FAIL > System info: > Raspbian GNU/Linux 8.0 (jessie) 32bit OS > Raspberry pi3b > telegraf is git clone the source form master
You've run into this bug[1] of the Go sync package: > On both ARM and x86-32, it is the caller's responsibility to arrange for > 64-bit alignment of 64-bit words accessed atomically. The first word in a > global variable or in an allocated struct or slice can be relied upon to be > 64-bit aligned. The simplest fix will be to move the field nMetrics as the first field of the Accumulator struct. Please open a PR or file an issue on the Telegraf GitHub repo. [1] https://golang.org/pkg/sync/atomic/#pkg-note-BUG -- Remember to include the version number! --- You received this message because you are subscribed to the Google Groups "InfluxData" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/influxdb. To view this discussion on the web visit https://groups.google.com/d/msgid/influxdb/632ee1cf-9b8b-4d81-988d-13ac82191a58%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
