svn commit: r1932662 - in apr/apr/trunk: .github/workflows test

[email protected] Mon, 30 Mar 2026 09:31:29 -0000
Newsgroups gmane.comp.apache.apr.cvs
Message-ID <177486308955.835233.17844093112748355843@svn03-he-fi>
Author: jorton
Date: Mon Mar 30 09:31:29 2026
New Revision: 1932662

Log:
Fix teststr segfault when built with `-ftrivial-auto-var-init`:

* 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 and also adds a new CI
workflow to cover this `-ftrivial-auto-var-init` compilation mode.

Submitted by: Dmitrii Kuvaiskii <dimakuv amazon.de>
GitHub: closes #71

Modified:
   apr/apr/trunk/.github/workflows/linux.yml
   apr/apr/trunk/test/teststr.c

Modified: apr/apr/trunk/.github/workflows/linux.yml
==============================================================================
--- apr/apr/trunk/.github/workflows/linux.yml	Mon Mar 30 08:30:17 2026	(r1932661)
+++ apr/apr/trunk/.github/workflows/linux.yml	Mon Mar 30 09:31:29 2026	(r1932662)
@@ -87,6 +87,9 @@ jobs:
             notest-cflags: -Werror
             config: --enable-maintainer-mode --with-berkeley-db --with-dbm=db5
             config-output: APU_HAVE_DB
+          - name: Auto-var-init
+            os: ubuntu-latest  # requires gcc 12 or higher
+            notest-cflags: -ftrivial-auto-var-init=zero
       fail-fast: false
 
     runs-on: ${{ matrix.os }}

Modified: apr/apr/trunk/test/teststr.c
==============================================================================
--- apr/apr/trunk/test/teststr.c	Mon Mar 30 08:30:17 2026	(r1932661)
+++ apr/apr/trunk/test/teststr.c	Mon Mar 30 09:31:29 2026	(r1932662)
@@ -48,10 +48,15 @@ static void test_strtok(abts_case *tc, v
             "      asdf jkl; 77889909            \r\n\1\2\3Z",
             " \r\n\3\2\1"
         },
+#if 0
+/* don't do this... apr_strtok() is not supposed to be called with
+ * str == NULL in the first invocation, otherwise it segfaults.
+ */
         {
-            NULL,  /* but who cares if apr_strtok() segfaults? */
+            NULL,
             " \t"
         },
+#endif
 #if 0     /* don't do this... you deserve to segfault */
         {
             "a b c              ",