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

Fix alignment of byte arrays inside tuples #2625

Merged
merged 1 commit into from
Jun 6, 2023

Conversation

viktormalik
Copy link
Contributor

@viktormalik viktormalik commented May 25, 2023

When using types internally represented by byte arrays inside tuples (e.g. usym, inet, etc.), LLVM aligns them to 1 byte inside the tuple. We must do the same in our internal type system so that the size of our type matches the size of the type generated by LLVM.

This also renames the SizedType::GetAlignment method to SizedType::GetInTupleAlignment as it's only used to get alignment of a type when it is used inside a tuple and the old name was confusing.

Added runtime and codegen tests for a case where bpftrace previously crashed.

Checklist
  • Language changes are updated in man/adoc/bpftrace.adoc and if needed in docs/reference_guide.md
  • User-visible and non-trivial changes updated in CHANGELOG.md
  • The new behaviour is covered by tests

When using types internally represented by byte arrays inside tuples
(e.g. usym, inet, etc.), LLVM aligns them to 1 byte inside the tuple. We
must do the same in our internal type system so that the size of our
type matches the size of the type generated by LLVM.

This also renames the `SizedType::GetAlignment` method to
`SizedType::GetInTupleAlignment` as it's only used to get alignment of a
type when it is used inside a tuple and the old name was confusing.

Added runtime and codegen tests for a case where bpftrace previously
crashed.
@viktormalik viktormalik merged commit 64048ac into bpftrace:master Jun 6, 2023
@viktormalik viktormalik deleted the bytearray-align branch June 23, 2023 07:17
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.

3 participants