8000 Memory alignement issue on ARMv7 · Issue #12 · tidwall/tg · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Memory alignement issue on ARMv7 #12

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

Open
abeggc opened this issue Apr 29, 2025 · 3 comments
Open

Memory alignement issue on ARMv7 #12

abeggc opened this issue Apr 29, 2025 · 3 comments

Comments

@abeggc
Copy link
Contributor
abeggc commented Apr 29, 2025

When loading GeoBIN files on ARMv7 cpus, there is a memory alignment issue while reading the WKB coordinates directly in the parse_wkb_posns function and this crashes the program with a bus error:

Extract from dmesg:

Alignment trap: not handling instruction edda3b00 at [<00430638>]
8<--- cut here ---
Unhandled fault: alignment exception (0x011) at 0xb65ee549
[b65ee549] *pgd=36804831

The instruction corresponds to VLDM which requires 8 bytes alignment, which isn't always the case.

To avoid this issue, the points can be forced to be read with the read_posn.
Here's a proposition to fix it: main...abeggc:tg:bugfix/mem-align-arm
Let me know and I can create a pull request.

@tidwall
Copy link
Owner
tidwall commented Apr 29, 2025

Nice find. I was able to reproduce the bug.
Feel free to open the PR.

@tidwall
Copy link
Owner
tidwall commented Apr 30, 2025

I just merged your PR.

I also made a small change which speeds the loads up a bit. I moved the alignment check into the first block and then loaded the unaligned doubles into new allocation. This was about 2x faster than using the read_posn block, which is really only intended for reading doubles from WKB that has a different endianness than the cpu.

Thanks!

-->

@abeggc
Copy link
Contributor Author
abeggc commented May 1, 2025

Thanks for the merge and the speed up change, it works great!

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
0