Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 panic: unaligned 64-bit atomic operation [32 bit machines] #1487

Closed
hexiro opened this issue Aug 13, 2021 · 1 comment · Fixed by #1502
Closed

🐛 panic: unaligned 64-bit atomic operation [32 bit machines] #1487

hexiro opened this issue Aug 13, 2021 · 1 comment · Fixed by #1502

Comments

@hexiro
Copy link

hexiro commented Aug 13, 2021

Fiber version
v2.17.0

Issue description
On 32 bit machines, fiber sometimes crashes on startup when using certain middleware.
I believe this is something to do with sync/atomic

https://pkg.go.dev/sync/atomic#pkg-note-BUG

On 386, the 64-bit functions use instructions unavailable before the Pentium MMX.

On non-Linux ARM, the 64-bit functions use instructions unavailable before the ARMv6k core.

On ARM, 386, and 32-bit MIPS, it is the caller's responsibility to arrange for 64-bit alignment of 64-bit words accessed atomically. The first word in a variable or in an allocated struct, array, or slice can be relied upon to be 64-bit aligned.

Code snippet

package main

import (
        "github.com/gofiber/fiber/v2"
        "github.com/gofiber/fiber/v2/middleware/limiter"
        "log"
)

func main()  {
        app := fiber.New()
        app.Use(limiter.New())
        log.Fatal(app.Listen(":3000"))
}
panic: unaligned 64-bit atomic operation

goroutine 20 [running]:
runtime/internal/atomic.panicUnaligned()
        /usr/local/go/src/runtime/internal/atomic/unaligned.go:8 +0x24
runtime/internal/atomic.Store64(0x1d0016c, 0x6116b072, 0x0)
        /usr/local/go/src/runtime/internal/atomic/asm_arm.s:278 +0x14
github.com/gofiber/fiber/v2/internal/memory.(*Storage).updater(0x1d00150, 0x3b9aca00, 0x0)
        /home/pi/go/pkg/mod/github.com/gofiber/fiber/v2@v2.17.0/internal/memory/memory.go:69 +0x40
created by github.com/gofiber/fiber/v2/internal/memory.New
        /home/pi/go/pkg/mod/github.com/gofiber/fiber/v2@v2.17.0/internal/memory/memory.go:26 +0x128
@welcome
Copy link

welcome bot commented Aug 13, 2021

Thanks for opening your first issue here! 🎉 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

ReneWerner87 added a commit to ReneWerner87/fiber that referenced this issue Aug 22, 2021
…1487

change from uin64 to uint32 for the timestamp -> max value is 4294967295 -> Sun Feb 07 2106 06:28:15 GMT+0000
ReneWerner87 added a commit that referenced this issue Aug 22, 2021
…#1502)

* 🐛 panic: unaligned 64-bit atomic operation [32 bit machines] #1487
https://pkg.go.dev/sync/atomic#pkg-notes
https://go101.org/article/memory-layout.html
golang/go#36606

* 🐛 panic: unaligned 64-bit atomic operation [32 bit machines] #1487
change from uin64 to uint32 for the timestamp -> max value is 4294967295 -> Sun Feb 07 2106 06:28:15 GMT+0000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants