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 test runner constructors order and _FORTIFY_SOURCE failure #729

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

Conversation

ArtSin
Copy link

@ArtSin ArtSin commented Nov 26, 2024

When building with clang (18.1.8 on x86_64-linux-gnu) and _FORTIFY_SOURCE=2 (or 3), I noticed that only half of the unit-test tests were run, which didn't happen with _FORTIFY_SOURCE=0. It turns out that fortified memset and _##S##_init were not optimized out, as in the case of _FORTIFY_SOURCE=0, and due to undefined order of constructors, arrays were zeroed after tests were added to them. The first commit sets the order of all functions with __attribute__((constructor)).

After fixing the first issue, tuple/decoder/type/iso8601 failed because strcpy was passed a pointer to a subarray of size 8 instead of the whole buffer. The second commit fixes this.

If the order is undefined, test arrays can be zeroed after initialization.
Pass pointer to the buffer instead of a subarray which is too small for the whole string.
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