socketcluster-client-go icon indicating copy to clipboard operation
socketcluster-client-go copied to clipboard

Library does not work on ARM6

Open breiting opened this issue 7 years ago • 4 comments

I just tested the library on a Raspberry Pi (ARM6), however, it crashes with the following message:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x120b8]

goroutine 6 [running]:
runtime/internal/atomic.goXadd64(0x1462b4c, 0x1, 0x0, 0x1414300, 0xdd3e8)
	/opt/go/src/runtime/internal/atomic/atomic_arm.go:96 +0x1c
github.com/sacOO7/socketcluster-client-go/scclient/utils.(*AtomicCounter).IncrementAndGet(0x1462b4c, 0x6b980, 0x1464120)
	/home/pi/go/pkg/mod/github.com/sac!o!o7/[email protected]/scclient/utils/counter.go:12 +0x30
github.com/sacOO7/socketcluster-client-go/scclient.(*Client).sendHandshake(0x1462b40)
	/home/pi/go/pkg/mod/github.com/sac!o!o7/[email protected]/scclient/client.go:116 +0x24
github.com/sacOO7/socketcluster-client-go/scclient.(*Client).registerCallbacks.func1(0x14dc000, 0x1448340, 0x14180c0, 0x25, 0x100, 0x0, 0x0, 0x0, 0x0, 0x1446b60, ...)
	/home/pi/go/pkg/mod/github.com/sac!o!o7/[email protected]/scclient/client.go:44 +0x24
github.com/sacOO7/gowebsocket.(*Socket).Connect(0x1462b54)
	/home/pi/go/pkg/mod/github.com/sac!o!o7/[email protected]/gowebsocket.go:96 +0x390
github.com/sacOO7/socketcluster-client-go/scclient.(*Client).Connect(0x1462b40)
	/home/pi/go/pkg/mod/github.com/sac!o!o7/[email protected]/scclient/client.go:112 +0xcc

After digging in, I found a reasonable explanation for that problem, memory alignment.

I patched the code, which now works on ARM6, see my PR:

https://github.com/sacOO7/socketcluster-client-go/pull/11

Would be great to get that fix in, and v1.0.1 is released.

breiting avatar Jan 24 '19 12:01 breiting

Any comments on my fix @sacOO7 ?

breiting avatar Jun 13 '19 17:06 breiting

Did you compile it for ARM6? Because raspberry pi is ARM7 I guess they're supposed to all be backwards compatible though so it might not matter

G2G2G2G avatar Sep 08 '20 10:09 G2G2G2G

I think this was a pretty old Pi, which is/was ARM6.

breiting avatar Sep 08 '20 16:09 breiting

Only the original Pi is ARM6 (single core cpu) (just fyi) idk how much difference it makes, I see floating points are quite a bit different on them but entire OSes from ARMv6 seem to run on even armv8 cpus. So the backwards compatibility is good. But just so you know.. and the new raspberry pi 2,3,4 are Armv8, I was wrong, they aren't even armv7 but the OSes are all arm7 currently.

G2G2G2G avatar Sep 08 '20 16:09 G2G2G2G