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

Alignment error when using an ARM processor #58

Closed
AlexAUT opened this issue Jul 10, 2020 · 3 comments
Closed

Alignment error when using an ARM processor #58

AlexAUT opened this issue Jul 10, 2020 · 3 comments
Assignees
Labels

Comments

@AlexAUT
Copy link
Contributor

AlexAUT commented Jul 10, 2020

All DataView::toX functions directly cast the pointer without taking alignment into account. This unaligned access will only have a performance penalty on x86 CPUs, however, on ARM CPUs this results in a crash due to the unaligned memory access.
https://github.com/nem0/OpenFBX/blob/master/src/ofbx.cpp#L304

Copying into a stack variable is one way to remove the unaligned access, not sure if it is the most performant way to fix this.

double result;
memcpy(&result, begin, sizeof(double));
return result;
@nem0
Copy link
Owner

nem0 commented Jul 10, 2020

It's actually undefined behaviour the way it is now. I just did not care and did not expect it to be run on something else than PC HW. memcpy is the best solution, I will fix it soon, but I don't have ARM to test it.

@nem0 nem0 self-assigned this Jul 10, 2020
@nem0 nem0 added the bug label Jul 10, 2020
@AlexAUT
Copy link
Contributor Author

AlexAUT commented Jul 10, 2020

Thank you (and also for the great library). I could also create a quick pull-request if you want? Since I have already made the change in my local repo.

@nem0
Copy link
Owner

nem0 commented Jul 10, 2020

sure, PR would be great, thanks.

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

No branches or pull requests

2 participants