s-yata / marisa-trie

MARISA: Matching Algorithm with Recursively Implemented StorAge
Other
506 stars 89 forks source link

Fix armv7a alignment. Cause unaligned memory visit is not allowed. #47

Closed fuzzywang closed 2 years ago

fuzzywang commented 2 years ago

Unaligned memory visit is not allowed in armv7a, so just memcpy T to make it works.

jmr commented 2 years ago

How are you getting these errors? Which fields? How are the files written/read?

There's code to keep things aligned: https://github.com/s-yata/marisa-trie/blob/006020c1df76d0d7dc6118dacc22da64da2e35c4/lib/marisa/grimoire/vector/vector.h#L205

fuzzywang commented 2 years ago

I concat all resources file including marisa dump file as the Android assets. Then mmap and split them. So the file may not be aligned.

jmr commented 2 years ago

Align before you write the marisa data by either seeking or writing 0 bytes. For some reason, 16 byte alignment sticks in my head, but the code I pointed to is only 8 byte aligned. Does that fix it?

fuzzywang commented 2 years ago

Writing 0 bytes before concat fix that. Thanks