Fix teststr segfault when built with -ftrivial-auto-var-init#71
Open
dimakuv wants to merge 1 commit intoapache:trunkfrom
Open
Fix teststr segfault when built with -ftrivial-auto-var-init#71dimakuv wants to merge 1 commit intoapache:trunkfrom
-ftrivial-auto-var-init#71dimakuv wants to merge 1 commit intoapache:trunkfrom
Conversation
* test/teststr.c -- one test case was broken and worked by accident: the apr_strtok() function was intentionally called with `str == NULL` on first invocation. This leads to an access to `*internal_state`, which is technically undefined (uninitialized pointer on the stack). Without `-ftrivial-auto-var-init`, the `*internal_state` is benign by accident: the previous test case left the pointer-on-stack with some reasonable address. However, with `-ftrivial-auto-var-init=zero`, the `*internal_state` access fails because `internal_state = NULL` (auto-initialized to zero). So the whole test segfaults. This commit comments out this broken test case.
Contributor
|
@dimakuv could you try adding another CI workflow to cover this compilation mode? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The apr test suite has a test error (segfault) when built with
-ftrivial-auto-var-init=zero:Debug stack trace:
Root cause analysis:
apr/test/teststr.c
Line 52 in e461da5
apr/test/teststr.c
Line 81 in e461da5
apr_strtok(str, sep, internal_state)function must not be called withstr == NULLin the first invocation. However the test does exactly this, and this leads to an access to*internal_state, which is technically undefined (uninitialized pointer on the stack).-ftrivial-auto-var-init=zero, the*internal_stateis benign by accident: the previous test case left the pointer-on-stack with some reasonable address. However, with-ftrivial-auto-var-init=zero, the*internal_stateaccess fails becauseinternal_state = NULL(auto-initialized to zero). So the whole test segfaults.Reproducer
Note that
-ftrivial-auto-var-init=zeroflag was introduced in GCC v12.Testing the fix