[Bug 250954] ptrace(): weird ordering between inheriting debug registers and reporting a new thread

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Sun Nov 8 15:01:54 UTC 2020


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=250954

            Bug ID: 250954
           Summary: ptrace(): weird ordering between inheriting debug
                    registers and reporting a new thread
           Product: Base System
           Version: 12.2-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs at FreeBSD.org
          Reporter: mgorny at gentoo.org
                CC: emaste at freebsd.org, kib at FreeBSD.org

Disclaimer: I'm not sure if it's a bug or just a surprising behavior.  Please
consider the following case:

1. The debugger enables reporting new threads via PT_SET_EVENT_MASK.

2. Debugged program creates a thread (e.g. via pthread_create() or
std::thread).

3. Debugged program is stopped immediately afterwards (e.g. due to breakpoint).

Now, I can reliably reproduce that the kernel reports the breakpoint (trace
trap) *before* the new thread.  However, it seems that the thread is already
created at this point -- if the debugger alters debug registers in the main
thread, the new thread has the previous value.

Is dbreg inheritance something we want programmers to rely on?

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list