[Bug testsuite/34425] [gdb/testsuite] FAIL: gdb.threads/leader-exit.exp: single thread has been left

"cvs-commit at gcc dot gnu.org via Gdb-prs" <[email protected]>
Newsgroups gmane.comp.gdb.bugs.discuss
Message-ID <[email protected]/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=34425

--- Comment #2 from Sourceware Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <[email protected]>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1fba9bb362c6ca7a0ae30f0fff7d8c1d68f8bdb4

commit 1fba9bb362c6ca7a0ae30f0fff7d8c1d68f8bdb4
Author: Tom de Vries <[email protected]>
Date:   Sat Jul 25 08:59:51 2026 +0200

    [gdb/testsuite] Fix race in gdb.threads/leader-exit.exp

    On aarch64-linux, when running test-case gdb.threads/leader-exit.exp with
    "taskset -c 0", 3 out of 10 times I run into:
    ...
    (gdb) continue
    Continuing.
    [New Thread 0xfffff7d1f160 (LWP 62010) (id 2)]
    [Switching to thread 2 (Thread 0xfffff7d1f160 (LWP 62010))]

    Thread 2 "leader-exit" hit Breakpoint 2, start (arg=0x0) at
leader-exit.c:32
    32        sleep (10);  /* break-here */
    (gdb) PASS: gdb.threads/leader-exit.exp: continue to breakpoint: break-here
    info threads
      Id   Target Id                                                 Frame
      1    Thread 0xfffff7fe8020 (LWP 62008) "leader-exit" (Exiting) \
             0x0000fffff7d46fa0 in __libc_start_call_main () from
/lib64/libc.so.6
    * 2    Thread 0xfffff7d1f160 (LWP 62010) "leader-exit" \
             start (arg=0x0) at leader-exit.c:32
    (gdb) FAIL: gdb.threads/leader-exit.exp: single thread has been left
    ...

    In a passing version, the continue produces a "Thread exited" message, but
    that's missing here.

    The problem is that after the pthread_join is executed:
    ...
      i = pthread_join (main_thread, NULL);
      ...

      sleep (10);  /* break-here */
    ...
    there's a race between:
    - the breakpoint at break-here triggering, and
    - the "Thread exited" message for the main thread being reported.

    Fix this by:
    - adding a loop before the break location
    - waiting in the loop until the "Thread exited" message is seen
    - sending ^C to get a prompt
    - setting a variable to exit the loop

    Likewise in gdb.threads/non-ldr-exc-2.exp.

    Reviewed-By: Keith Seitz <[email protected]>
    Approved-By: Kevin Buettner <[email protected]>

    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34425

-- 
You are receiving this mail because:
You are on the CC list for the bug.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.