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

Align zero-length array to avoid unaligned accesses #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mattst88
Copy link

@mattst88 mattst88 commented Aug 7, 2019

When make_tree() creates the left-justified base table (uint64_t *B)
it does so with 64-bit stores:

B[k] = sofar;

But B points to memory in the zero-length array "uint32_t tt[0]" at the
end of struct decoder_state. Since tt's type is uint32_t, it is only
aligned to a four byte boundary, and so the 64-bit store in make_tree()
causes an unaligned trap on strict platforms like sparc.

When make_tree() creates the left-justified base table (uint64_t *B)
it does so with 64-bit stores:

    B[k] = sofar;

But B points to memory in the zero-length array "uint32_t tt[0]" at the
end of struct decoder_state. Since tt's type is uint32_t, it is only
aligned to a four byte boundary, and so the 64-bit store in make_tree()
causes an unaligned trap on strict platforms like sparc.
@mattst88
Copy link
Author

mattst88 commented Aug 7, 2019

If/when you take this patch, it would also be nice to make a 2.6 or 3.0 release. There is a ton of improvements since 2.5.

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.

1 participant