sipcapture / heplify

Portable and Lightweight HEP Capture Agent for HOMER
https://sipcapture.org
GNU Affero General Public License v3.0
181 stars 65 forks source link

heplify 1.63/go1.16.5 on armv7l causes panic: unaligned 64-bit atomic operation #216

Closed rpn0709 closed 1 year ago

rpn0709 commented 3 years ago

panic: unaligned 64-bit atomic operation

goroutine 13 [running]: runtime/internal/atomic.panicUnaligned() /usr/local/go/src/runtime/internal/atomic/unaligned.go:8 +0x24 runtime/internal/atomic.Load64(0x6d2639c, 0x0, 0x450cd8) /usr/local/go/src/runtime/internal/atomic/asm_arm.s:263 +0x14 github.com/sipcapture/heplify/decoder.(Decoder).printPacketStats(0x6d26000) /root/heplify-1.63/decoder/util.go:101 +0x2c github.com/sipcapture/heplify/decoder.(Decoder).printStats(0x6d26000, 0xf8475800, 0xd) /root/heplify-1.63/decoder/util.go:129 +0x5c created by github.com/sipcapture/heplify/decoder.NewDecoder /root/heplify-1.63/decoder/decoder.go:145 +0x5a4

tcreek commented 2 years ago

I am getting something similar, but I compiled the source with Go version 1.18.4

panic: unaligned 64-bit atomic operation

goroutine 31 [running]:
runtime/internal/atomic.panicUnaligned()
        /usr/local/go/src/runtime/internal/atomic/unaligned.go:8 +0x24
runtime/internal/atomic.Xadd64(0x682c39c, 0x1)
        /usr/local/go/src/runtime/internal/atomic/atomic_arm.s:258 +0x14
github.com/sipcapture/heplify/decoder.(*Decoder).Process(0x682c000, {0x68ae000, 0x21b, 0x21b}, 0x68ac0f0)
        /usr/src/heplify-1.63/decoder/decoder.go:225 +0xb80
github.com/sipcapture/heplify/sniffer.(*MainWorker).OnPacket(0x14905d8, {0x68ae000, 0x21b, 0x21b}, 0x68ac0f0)
        /usr/src/heplify-1.63/sniffer/sniffer.go:72 +0x40
github.com/sipcapture/heplify/sniffer.(*SnifferSetup).Run(0x14bc360)
        /usr/src/heplify-1.63/sniffer/sniffer.go:318 +0x850
main.main.func2()
        /usr/src/heplify-1.63/main.go:138 +0x2c
created by main.main
        /usr/src/heplify-1.63/main.go:137 +0x13c
cmsmith1977 commented 1 year ago

I found a similar issue in another project (https://github.com/hashicorp/consul/pull/10515) , and was able to move the _ entry in this struct to the end of the struct to fix this

diff --git a/decoder/decoder.go b/decoder/decoder.go
index f6ff9d9..2affade 100644
--- a/decoder/decoder.go
+++ b/decoder/decoder.go
@@ -50,7 +50,6 @@ type Decoder struct {
 }

 type stats struct {
-       _             uint32
        fragCount     uint64
        dupCount      uint64
        dnsCount      uint64
@@ -63,6 +62,7 @@ type stats struct {
        sctpCount     uint64
        udpCount      uint64
        unknownCount  uint64
+       _             uint32
 }

 type Packet struct {