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 some size arguments passed to ASSERT_ALLOC #6422

Open
gilles-peskine-arm opened this issue Oct 14, 2022 · 0 comments
Open

Fix some size arguments passed to ASSERT_ALLOC #6422

gilles-peskine-arm opened this issue Oct 14, 2022 · 0 comments
Labels
bug component-test Test framework and CI scripts size-s Estimated task size: small (~2d)

Comments

@gilles-peskine-arm
Copy link
Contributor

ASSERT_ALLOC(p, n) allocates room for n elements, not bytes. Its core is p = calloc(sizeof(*p), n). But we've been using it wrong, e.g. #6419 and in recent bignum core tests. After discussion, we've decided to rename the macro to xxx_CALLOC so that it's less error-prone.

The goal of this issue is to investigate and fix the existing usage, i.e. look for and fix places where the pointer is to a non-byte-sized type and the size is expressed in bytes rather than elements. We can identify the places where the element size is not 1 by tweaking the definition of ASSERT_ALLOC and causing a build failure (or probably, with GCC exensions, a warning) when the size is not 1.

This is likely to conflict with #6421 so they should either be done together or sequentially, not in parallel. It would probably be best to do #6421 first, then wait a bit until there is no more work in flight that uses the old name, and then fix the remaining usage and remove the old error-prone name.

@gilles-peskine-arm gilles-peskine-arm added bug size-s Estimated task size: small (~2d) component-test Test framework and CI scripts labels Oct 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug component-test Test framework and CI scripts size-s Estimated task size: small (~2d)
Projects
None yet
Development

No branches or pull requests

1 participant