FAQ
Hi list,

I found that atomic operations always panic on my Raspberry Pi 2, is it
possible to be a bug?

type S struct {
     a uint32
     b int64
}

func main() {
     s := new(S)
     atomic.StoreInt64(&s.b, 0)
}


--
Regards,
Fan Yang

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

Search Discussions

  • Jan Mercl at Nov 22, 2015 at 8:48 am
    On Sun, Nov 22, 2015 at 9:33 AM Yang Fan wrote:

    Hi list,
    I found that atomic operations always panic on my Raspberry Pi 2, is it
    possible to be a bug?

    Yes, it is a bug. Field b does not have the required 64bit alignment as
    documented at https://golang.org/pkg/sync/atomic/#pkg-note-BUG


    --

    -j

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Dave Cheney at Nov 22, 2015 at 8:48 am
    This is a known issue with the 32bit compiler. https://golang.org/pkg/sync/atomic/

    The simple solution is to move the 64bit field to the top of the struct, the compiler guarantees that struct allocations are always double word aligned.

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Yang Fan at Nov 22, 2015 at 8:57 am
    Got it. Thanks in advance.
    On Sun, Nov 22, 2015 at 4:48 PM, Dave Cheney wrote:

    This is a known issue with the 32bit compiler.
    https://golang.org/pkg/sync/atomic/

    The simple solution is to move the 64bit field to the top of the struct,
    the compiler guarantees that struct allocations are always double word
    aligned.

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


    --
    Regards,
    Fan Yang

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedNov 22, '15 at 8:33a
activeNov 22, '15 at 8:57a
posts4
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase