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

Avoid unaligned memory access in the PSM loader #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ccawley2011
Copy link

This can cause crashes on older ARM processors, as well as on newer ones with alignment exceptions enabled.

@sezero
Copy link
Contributor

sezero commented Apr 9, 2022

There are many other places in code that does foo = *(DWORD *)src; (or
foo = *(WORD *)src) which are potentially unaligned accesses. I ended
up with this yet-incomplete and to-be-verified patch: patch.txt.

ReadSample() of sndfile.c possibly needs similar love & care, not sure.
And several of the loaders would need revising for endian and alignment
safety.

@AliceLR
Copy link
Contributor

AliceLR commented Apr 9, 2022

Does #pragma pack(1) on the affected structs not already fix this?
edit: seems whether or not this forces the compiler to emit unaligned access safe code might be target-dependent.

@Apaczer
Copy link

Apaczer commented Jan 24, 2023

@ccawley2011, thank you immensly! It helped almost fully to eliminate PSM_Load errors on ARM32 device!.

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.

4 participants