[PATCH v2 0/2] MR11071: ntdll: Ignore hardware breakpoint traps inside the signal stack.
Ignore hardware-breakpoint traps raised to avoid recursively dispatching a trap through the Unix signal handler when user code installs a hardware breakpoint that is also reached from Wine's signal-handling path. This is split up from https://gitlab.winehq.org/wine/wine/-/merge_requests/11069 as asked. -- v2: Apply 1 suggestion(s) to 1 file(s) https://gitlab.winehq.org/wine/wine/-/merge_requests/11071
From: Soham Nandy <soham.nandy2006@gmail.com> Ignore hardware-breakpoint traps raised to avoid recursively dispatching a trap through the Unix signal handler when user code installs a hardware breakpoint that is also reached from Wine's signal-handling path --- dlls/ntdll/unix/signal_x86_64.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c index 41293fe5607..c48636ee194 100644 --- a/dlls/ntdll/unix/signal_x86_64.c +++ b/dlls/ntdll/unix/signal_x86_64.c @@ -2149,9 +2149,12 @@ static BOOL handle_syscall_trap( struct thread_data *data, ucontext_t *sigcontex R10_sig( sigcontext ) = RCX_sig( sigcontext ); fixup_frame_fpu_state( frame, sigcontext ); } - else if (siginfo->si_code == 4 /* TRAP_HWBKPT */ && is_inside_syscall( data, RSP_sig(sigcontext) )) + else if (siginfo->si_code == 4 /* TRAP_HWBKPT */ && + (is_inside_syscall( data, RSP_sig(sigcontext) ) || + is_inside_signal_stack( data, (void *)RSP_sig(sigcontext) ))) { - TRACE_(seh)( "ignoring HWBKPT in syscall rip=%p\n", (void *)RIP_sig(sigcontext) ); + TRACE_(seh)( "ignoring HWBKPT in syscall/signal stack rip=%p\n", + (void *)RIP_sig(sigcontext) ); return TRUE; } else return FALSE; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11071
From: Soham Nandy <soham.nandy2006@gmail.com> Co-authored-by: Paul Gofman <pgofman@codeweavers.com> --- dlls/ntdll/unix/signal_x86_64.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c index c48636ee194..16a3484a47a 100644 --- a/dlls/ntdll/unix/signal_x86_64.c +++ b/dlls/ntdll/unix/signal_x86_64.c @@ -2154,7 +2154,12 @@ static BOOL handle_syscall_trap( struct thread_data *data, ucontext_t *sigcontex is_inside_signal_stack( data, (void *)RSP_sig(sigcontext) ))) { TRACE_(seh)( "ignoring HWBKPT in syscall/signal stack rip=%p\n", - (void *)RIP_sig(sigcontext) ); + else if (siginfo->si_code == 4 /* TRAP_HWBKPT */ && (is_inside_syscall( data, RSP_sig(sigcontext) ) + || is_inside_signal_stack( data, (void *)RSP_sig(sigcontext) ))) + { + TRACE_(seh)( "ignoring HWBKPT rip=%p\n", (void *)RIP_sig(sigcontext) ); + return TRUE; + } return TRUE; } else return FALSE; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11071
On Thu Jun 4 21:18:35 2026 +0000, Elizabeth Figura wrote:
For traceability, the application in question sets R/W breakpoints on several locations in the USD, including ProcessorFeatures[PF_RDWRFSGSBASE_AVAILABLE]. The application takes a SEGV and then the SEGV handler trips the breakpoint. Yeah. An app is definitely free to set the hwbpt anywhere in userspace address range, it could be TEB (on which occasion handling that for syscall was added) or, just e. g., IOSB block to be written from SIGUSR1. So generic handling of that (without much of a trouble) looks correct.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/11071#note_142248
participants (3)
-
Paul Gofman (@gofman) -
Soham Nandy -
Soham Nandy (@natimerry)