public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug python/28825] New: Breakpoints fire multiple times after fork() call
@ 2022-01-27  7:02 fasching.a91 at gmail dot com
  2022-01-27  7:15 ` [Bug python/28825] " fasching.a91 at gmail dot com
  0 siblings, 1 reply; 2+ messages in thread
From: fasching.a91 at gmail dot com @ 2022-01-27  7:02 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 28825
           Summary: Breakpoints fire multiple times after fork() call
           Product: gdb
           Version: 11.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: python
          Assignee: unassigned at sourceware dot org
          Reporter: fasching.a91 at gmail dot com
  Target Milestone: ---

Created attachment 13932
  --> https://sourceware.org/bugzilla/attachment.cgi?id=13932&action=edit
program and script to reproduce the described behavior

Breakpoints for a function fire multiple times if they happen after a fork(),
even though the function is only called once.
This doesn't happen if there's some delay (e.g. a sleep) between the fork() and
the function call.

Steps to reproduce:

1. Required files
--------------------------------------
$ cat fork.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

void bar(void) {
    printf("this is bar()\n");
}

int main(int argc, char **argv) {
    if (!fork())
        exit(0);
    // sleep(1);  // Doesn't happen after sleeping.
    bar();
    return 0;
}


$ cat script.py
import gdb

class Breakpoint(gdb.Breakpoint):
    def stop(self):
        print("breakpoint fired")

bp = Breakpoint("bar")
gdb.execute("run")


2. Compile
--------------------------------------
$ gcc -g -O0 -o fork fork.c


3. Run
--------------------------------------
$ gdb --batch -x script.py fork
Breakpoint 1 at 0x115d: file fork.c, line 6.
[Detaching after fork from child process 33489]
breakpoint fired
breakpoint fired
this is bar()
[Inferior 1 (process 33485) exited normally]

I can reproduce this with GDB 8.2 and 11.1 and haven't tried any releases in
between.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug python/28825] Breakpoints fire multiple times after fork() call
  2022-01-27  7:02 [Bug python/28825] New: Breakpoints fire multiple times after fork() call fasching.a91 at gmail dot com
@ 2022-01-27  7:15 ` fasching.a91 at gmail dot com
  0 siblings, 0 replies; 2+ messages in thread
From: fasching.a91 at gmail dot com @ 2022-01-27  7:15 UTC (permalink / raw)
  To: gdb-prs

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

Alexander Fasching <fasching.a91 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fasching.a91 at gmail dot com

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-27  7:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-27  7:02 [Bug python/28825] New: Breakpoints fire multiple times after fork() call fasching.a91 at gmail dot com
2022-01-27  7:15 ` [Bug python/28825] " fasching.a91 at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).