sacOO7 / socketcluster-client-go

GO client for socketcluster
https://socketcluster.io/
Apache License 2.0
54 stars 20 forks source link

Library does not work on ARM6 #10

Open breiting opened 5 years ago

breiting commented 5 years ago

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/socketcluster-client-go@v1.0.0/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/socketcluster-client-go@v1.0.0/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/socketcluster-client-go@v1.0.0/scclient/client.go:44 +0x24
github.com/sacOO7/gowebsocket.(*Socket).Connect(0x1462b54)
    /home/pi/go/pkg/mod/github.com/sac!o!o7/gowebsocket@v0.0.0-20180719182212-1436bb906a4e/gowebsocket.go:96 +0x390
github.com/sacOO7/socketcluster-client-go/scclient.(*Client).Connect(0x1462b40)
    /home/pi/go/pkg/mod/github.com/sac!o!o7/socketcluster-client-go@v1.0.0/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 commented 5 years ago

Any comments on my fix @sacOO7 ?

G2G2G2G commented 3 years ago

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

breiting commented 3 years ago

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

G2G2G2G commented 3 years ago

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.