[go-nuts] Re: Cross-compiled program for Raspberry Pi crashes

2018-08-14 Thread Stephan Mühlstrasser
Am Montag, 13. August 2018 23:47:11 UTC+2 schrieb Dave Cheney:
>
> I don’t think that will help. The problem is not cross compilation. The 
> problem is when run in a 32bit environment the offset of that field is not 
> guaranteed to be aligned to 8 bytes. You’ve got a 50/50 chance that each 
> allocation will be properly aligned.


That sounds like a pretty severe compiler bug then. This makes it more or 
less impossible to use any third-party libraries with Go on ARM unless you 
check them and all their dependencies whether they use sync/atomic. 
Apparently the Google Cloud Go APIs fall into this category and should not 
be used on ARM 32-bit.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Cross-compiled program for Raspberry Pi crashes

2018-08-13 Thread Stephan Mühlstrasser

Am Montag, 13. August 2018 22:36:56 UTC+2 schrieb Dave Cheney:
>
> No, it’s not a cross compilation issue. Well, yes and no, the rpi is a 32 
> bit platform so some structures have a different size causing the offset of 
> the field to be 32 but aligned, not the required 64 bit aligned. 
>
> The play example shows the address of the field is not aligned on a 8 byte 
> boundary. 
>

Ah, I didn't recognize that the number in the play example is the 
problematic address from the stack trace.

Short version, move the field to the top of the structure which is 
> guaranteed to be properly aligned.


Ok, thank you. I now realized that I would have to change structures in 
third party software, so this is probably not a reasonable approach. I will 
have to live with the fact that I have to compile on the Raspberry Pi 
itself, and I hope that the compiler bug will not manifest itself there.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Cross-compiled program for Raspberry Pi crashes

2018-08-13 Thread Stephan Mühlstrasser
Am Sonntag, 12. August 2018 23:30:22 UTC+2 schrieb Dave Cheney:
>
> This is likely to be issue https://github.com/golang/go/issues/599 
> 
> , https://play.golang.org/p/zZm-6zWwFoi
>
>  
Thanks for the diagnosis, this looks like the issue I'm seeing, although I 
don't understand how the example on play.golang.org 
 is related. The example does not 
crash if I run a cross-compiled binary on the Raspberry Pi and it prints 
the correct result "false".

So do I understand it correctly that this is a bug that is exclusive to the 
cross compiler? The native compiler on the Raspberry Pi apparently is able 
to compile the code correctly?

And is it possible to work around the bug, for example by adding padding or 
by re-arranging the problematic structure?

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Cross-compiled program for Raspberry Pi crashes

2018-08-12 Thread Stephan Mühlstrasser
Am Sonntag, 12. August 2018 19:33:19 UTC+2 schrieb Skip:
>
> Rpi1 model B requires setting GOARM=5 I believe.
>
>>
Thanks for the suggestion, I indeed have used GOARM=6. But I just verified 
that the crash still occurs also when I compile with GOARM=5.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Cross-compiled program for Raspberry Pi crashes

2018-08-12 Thread Stephan Mühlstrasser
Hi,

I'm developing my first Go program that is supposed to upload files into a 
Google Cloud Storage bucket from a Raspberry Pi 1. It uses the 
https://github.com/blackjack/webcam library to grab a picture from an USB 
camera.

I can compile the program on the Raspberry Pi itself with Go 1.7.4 that 
comes with Raspbian, and then it works as expected. However compilation on 
the Raspberry Pi is slow and it even sometimes fails because of memory 
shortage. Therefore I want to cross-compile on Windows.

When I cross-compile the exact same source on Windows for ARM with Go 
1.10.3, then this binary crashes at some point on the Raspberry Pi with a 
segmentation fault:

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


goroutine 8 [running]:
sync/atomic.addUint64(0x1236210c, 0x8a75f371, 0xa3f9cbd6, 0xdcd30e9, 
0xda39e1c1)
C:/Go/src/sync/atomic/64bit_arm.go:31 +0x4c
go.opencensus.io/trace.(*defaultIDGenerator).NewSpanID(0x123620f0, 0x0, 0x0)
E:/Users/stm/go/src/go.opencensus.io/trace/trace.go:483 +0x50
go.opencensus.io/trace.startSpanInternal(0x123202d0, 0x22, 0x0, 0x0, 0x0, 
0x0, 0x0, 0x0, 0x0, 0x0, ...)
E:/Users/stm/go/src/go.opencensus.io/trace/trace.go:196 +0x7c
go.opencensus.io/trace.StartSpan(0x4c4128, 0x12795c60, 0x123202d0, 0x22, 
0x123798ec, 0x2, 0x2, 0x10, 0x40, 0x58f74)
E:/Users/stm/go/src/go.opencensus.io/trace/trace.go:162 +0x128
...

I'm a Go newbie, and therefore I'm not sure how to interpret this. May this 
be a bug in the Go cross-compiler, or may this be a bug in the program that 
only manifests itself when the program is cross-compiled with the newer 
compiler on Windows?  How can I analyze this?

Thanks
Stephan

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.