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

fix atomic alignment on 32-bit platforms #305

Merged
merged 1 commit into from
Apr 6, 2022
Merged

Conversation

yplam
Copy link
Contributor

@yplam yplam commented Feb 17, 2022

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.

@Danielius1922
Copy link
Member

@jkralik Hmm, UBSan in C++ does alignment checks, maybe there's some Go tool that does it as well? Or at least we should probably run tests on a 32bit platform.

@ihidchaos
Copy link

Hi @jkralik @Danielius1922 developers, I also met this error on my OpenWRT platform.

[root@GW:/tmp/tmp]#cat /proc/cpuinfo 
system type		: MediaTek MT7628AN ver:1 eco:2
machine			: Jotale JS76x8 (32M)
processor		: 0
cpu model		: MIPS 24KEc V5.5
BogoMIPS		: 382.46
wait instruction	: yes
microsecond timers	: yes
tlb_entries		: 32
extra interrupt vector	: yes
hardware watchpoint	: yes, count: 4, address/irw mask: [0x0ffc, 0x0ffc, 0x0ffb, 0x0ffb]
isa			: mips1 mips2 mips32r1 mips32r2
ASEs implemented	: mips16 dsp
Options implemented	: tlb 4kex 4k_cache prefetch mcheck ejtag llsc pindexed_dcache userlocal vint perf_cntr_intr_bit perf
shadow register sets	: 1
kscratch registers	: 0
package			: 0
core			: 0
VCED exceptions		: not available
VCEI exceptions		: not available

goroutine 13 [running]:
runtime/internal/atomic.panicUnaligned(...)
	C:/Program Files/Go/src/runtime/internal/atomic/unaligned.go:8
runtime/internal/atomic.lockAndCheck(...)
	C:/Program Files/Go/src/runtime/internal/atomic/atomic_mipsx.go:38
runtime/internal/atomic.Load64(0x2a2fd54)
	C:/Program Files/Go/src/runtime/internal/atomic/atomic_mipsx.go:94 +0xa4
github.com/plgd-dev/go-coap/v2/udp/message/pool.(*Pool).ReleaseMessage(0x2a2fd40, 0x2a6e420)
	C:/Users/IHID/go/pkg/mod/github.com/plgd-dev/go-coap/v2@v2.5.1-0.20220331091656-0f32afde2208/udp/message/pool/message.go:197 +0x48
github.com/plgd-dev/go-coap/v2/udp/client.(*ClientConn).ReleaseMessage(...)
	C:/Users/IHID/go/pkg/mod/github.com/plgd-dev/go-coap/v2@v2.5.1-0.20220331091656-0f32afde2208/udp/client/clientconn.go:786
github.com/plgd-dev/go-coap/v2/udp/client.(*ClientConn).Process.func2.2(0x2874eb0, 0x2a58ce0)
	C:/Users/IHID/go/pkg/mod/github.com/plgd-dev/go-coap/v2@v2.5.1-0.20220331091656-0f32afde2208/udp/client/clientconn.go:734 +0x4c
github.com/plgd-dev/go-coap/v2/udp/client.(*ClientConn).Process.func2()
	C:/Users/IHID/go/pkg/mod/github.com/plgd-dev/go-coap/v2@v2.5.1-0.20220331091656-0f32afde2208/udp/client/clientconn.go:744 +0x458
github.com/plgd-dev/go-coap/v2/udp.glob..func2.2.1(0x2a58cd0)
	C:/Users/IHID/go/pkg/mod/github.com/plgd-dev/go-coap/v2@v2.5.1-0.20220331091656-0f32afde2208/udp/server.go:54 +0x3c
created by github.com/plgd-dev/go-coap/v2/udp.glob..func2.2
	C:/Users/IHID/go/pkg/mod/github.com/plgd-dev/go-coap/v2@v2.5.1-0.20220331091656-0f32afde2208/udp/server.go:53 +0x50

I have tested that this pull can solve it, can you merge it to the master branch?
Best Regards.
Guo

@jkralik jkralik merged commit 30f28f6 into plgd-dev:master Apr 6, 2022
@jkralik
Copy link
Member

jkralik commented Apr 6, 2022

Thx for contributing.

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 this pull request may close these issues.

None yet

4 participants