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 #8

Open
qiongkaka opened this issue Aug 16, 2023 · 1 comment
Open

panic: unaligned 64-bit atomic operation #8

qiongkaka opened this issue Aug 16, 2023 · 1 comment

Comments

@qiongkaka
Copy link

我将软件发布到arm 32位操作系统遇到了问题

打包命令如下:
set GOARCH=arm
set GOOS=linux
set CGO_ENABLED=0
go build -o ipchub_linux

运行时显示的错误信息:
panic: unaligned 64-bit atomic operation

goroutine 20 [running]:
runtime/internal/atomic.panicUnaligned()
E:/Program Files/Go/src/runtime/internal/atomic/unaligned.go:8 +0x24
runtime/internal/atomic.Store64(0x24881ec, 0x0)
E:/Program Files/Go/src/runtime/internal/atomic/atomic_arm.s:291 +0x14
github.com/cnotch/scheduler.(*Scheduler).run(0x24881c0)
C:/Users/Administrator/go/pkg/mod/github.com/cnotch/[email protected]/scheduler.go:226 +0xf0
created by github.com/cnotch/scheduler.New in goroutine 1
C:/Users/Administrator/go/pkg/mod/github.com/cnotch/[email protected]/scheduler.go:89 +0x274

@cnotch
Copy link
Owner

cnotch commented Aug 22, 2023

抱歉,很长时间没有关注这个项目了,我没有在32位系统测过。从显示的log看,是结构体对齐的问题。
可以将scheduler中的结构体中需要原子操作的count提到第一个,如下:
type Scheduler struct {
count int64 // 也就是这里
wg *sync.WaitGroup
add chan *ManagedJob
remove chan *ManagedJob
snapshot chan chan []*ManagedJob
panicHandler atomic.Value
loc *time.Location
ctx context.Context
cancel context.CancelFunc
terminated bool
}

这样确保64位字节对齐。
希望对您有所帮助。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants