[Bug breakpoints/34380] New: Conditional breakpoint miss due to race condition when false and true condition are set on nearby lines.

"abdul.basitijaz at gmail dot com via Gdb-prs" <[email protected]>
Newsgroups gmane.comp.gdb.bugs.discuss
Message-ID <[email protected]/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=34380

            Bug ID: 34380
           Summary: Conditional breakpoint miss due to race condition when
                    false and true condition are set on nearby lines.
           Product: gdb
           Version: HEAD
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: breakpoints
          Assignee: unassigned at sourceware dot org
          Reporter: abdul.basitijaz at gmail dot com
  Target Milestone: ---

Created attachment 16829
  --> https://sourceware.org/bugzilla/attachment.cgi?id=16829&action=edit
Reproducer Source file

Conditional breakpoint miss due to race condition when false and true condition
are set on the nearby lines. 

Two threads are running in the attached test. The False condition BP is set at
line 22 and True condition breakpoint is set at line 23. GDB is expected to
STOP twice at the line 23 but instead it just stopped once.

OS: Ubuntu22
GCC: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0
GDB Head: GNU gdb (GDB) 18.0.50.20260708-git

Reproducer is attached and can be rebuilt using:
gcc -g -pthread test.c -o test.exe


# Fail logs:

'''
gdb --batch -ex="break 22 if (tid<0)" -ex="break 23 if (tid>=0)" -ex="r"
-ex="c" -ex="c" ./test.exe

Breakpoint 1 at 0x1219: file test.c, line 22.
Breakpoint 2 at 0x1220: file test.c, line 23.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff7bff640 (LWP 351236) (id 2)]
[New Thread 0x7ffff73fe640 (LWP 351237) (id 3)]
[Switching to thread 2 (Thread 0x7ffff7bff640 (LWP 351236))]

Thread 2 "test.exe" hit Breakpoint 2, thread_func (arg=0x7fffffffdbc8) at
test.c:23
23        int y = 0;  /* cond-bp-true */
[Thread 0x7ffff73fe640 (LWP 351237) (id 3) exited]
[Thread 0x7ffff7bff640 (LWP 351236) (id 2) exited]
[Inferior 1 (process 351233) exited normally]
'''

# Expected behavior where now the FALSE condition is removed to get the
required result:

gdb --batch  -ex="break 23 if (tid>=0)" -ex="r" -ex="c" -ex="c" ./test.exe
Breakpoint 1 at 0x1220: file test.c, line 23.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff7bff640 (LWP 351221) (id 2)]
[New Thread 0x7ffff73fe640 (LWP 351222) (id 3)]
[Switching to thread 3 (Thread 0x7ffff73fe640 (LWP 351222))]

Thread 3 "test.exe" hit Breakpoint 1, thread_func (arg=0x7fffffffdbcc) at
test.c:23
23        int y = 0;  /* cond-bp-true */
[Switching to thread 2 (Thread 0x7ffff7bff640 (LWP 351221))]

Thread 2 "test.exe" hit Breakpoint 1, thread_func (arg=0x7fffffffdbc8) at
test.c:23
23        int y = 0;  /* cond-bp-true */
[Thread 0x7ffff73fe640 (LWP 351222) (id 3) exited]
[Thread 0x7ffff7bff640 (LWP 351221) (id 2) exited]
[Inferior 1 (process 351218) exited normally]

-- 
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.