Fix test runner constructors order and _FORTIFY_SOURCE failure - #729
Fix test runner constructors order and _FORTIFY_SOURCE failure#729ArtSin wants to merge 2 commits into
_FORTIFY_SOURCE failure#729Conversation
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.
|
Hey @ArtSin, thanks for the PR! |
The constructor order problem can be reproduced even with clang 10 in ubuntu 20.04; the |
|
Ping |
2ec54b4 to
3769fab
Compare
There was a problem hiding this comment.
Hi @ArtSin. Thanks for this PR.
I feel however that relying on the constructor just to zero everything is not the best way, unless I'm missing something. This is a critique to the current state of things not on your code, of course.
However I think we should take the chance and improve that instead of forcing an order on the constructors.
How about having those tests have an inline initialization? Like:
static MunitSuite _##S##_suites[TEST__CAP] = {};And remove the constructor from TEST_SUITE__DECLARE altogether?
When building with clang (18.1.8 on x86_64-linux-gnu) and
_FORTIFY_SOURCE=2(or 3), I noticed that only half of theunit-testtests were run, which didn't happen with_FORTIFY_SOURCE=0. It turns out that fortifiedmemsetand_##S##_initwere 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/iso8601failed becausestrcpywas passed a pointer to a subarray of size 8 instead of the whole buffer. The second commit fixes this.