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 on 32bit ARM processor #31

Closed
james7272 opened this issue Sep 21, 2021 · 2 comments · Fixed by #32
Closed

Panic on 32bit ARM processor #31

james7272 opened this issue Sep 21, 2021 · 2 comments · Fixed by #32

Comments

@james7272
Copy link

The following Unaligned panic occurs on a 32 bit ARM processor

runtime/internal/atomic.panicUnaligned()
	/usr/lib/go/src/runtime/internal/atomic/unaligned.go:8 +0x24
runtime/internal/atomic.Load64(0xf482b4)
	/usr/lib/go/src/runtime/internal/atomic/atomic_arm.s:286 +0x14
github.com/qmuntal/stateless.(*StateMachine).Firing(...)
	/home/andy/Documents/werk/software/products/xte/xte_dev/vendor/github.com/qmuntal/stateless/statemachine.go:268
	

A simple workaround is to re-arrange the StateMachine struct to place the 'ops' field first where it has the correct byte alignment.

type StateMachine struct {
	ops                    uint64
	stateConfig            map[State]*stateRepresentation
	triggerConfig          map[Trigger]triggerWithParameters
	stateAccessor          func(context.Context) (State, error)
	stateMutator           func(context.Context, State) error
	unhandledTriggerAction UnhandledTriggerActionFunc
	onTransitioningEvents  onTransitionEvents
	onTransitionedEvents   onTransitionEvents
	eventQueue             *list.List
	firingMode             FiringMode
	firingMutex            sync.Mutex
}

@qmuntal
Copy link
Owner

qmuntal commented Sep 21, 2021

This is unfortunate. Related to golang/go#23345.

The workaround is to move ops to the beginning of the struct, as @james7272 recommended.

I'll cut a new release with this fixed soon.

@james7272
Copy link
Author

Thanks for the prompt fix, much appreciated.

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

Successfully merging a pull request may close this issue.

2 participants