NetBSD Problem Report #54960

From www@netbsd.org  Thu Feb 13 15:17:57 2020
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id D80741A9213
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 13 Feb 2020 15:17:56 +0000 (UTC)
Message-Id: <20200213151756.17FEB1A9259@mollari.NetBSD.org>
Date: Thu, 13 Feb 2020 15:17:56 +0000 (UTC)
From: mgorny@gentoo.org
Reply-To: mgorny@gentoo.org
To: gnats-bugs@NetBSD.org
Subject: Concurrent signals to threads are reported multiple times via ptrace/SIGTRAP
X-Send-Pr-Version: www-1.0

>Number:         54960
>Category:       kern
>Synopsis:       Concurrent signals to threads are reported multiple times via ptrace/SIGTRAP
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 13 15:20:00 +0000 2020
>Originator:     Micha&#322; Górny
>Release:        NetBSD 9.99.46
>Organization:
>Environment:
System: NetBSD pomiocikbsd.local 9.99.46 NetBSD 9.99.46 (GENERIC) #1: Thu Feb 13 13:13:04 CET 2020 root@pomiocikbsd.local:/usr/obj/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64

>Description:
A multithreaded program is being debugged via ptrace().  The individual threads receive (different) signals concurrently (via pthread_kill()).  The debugger receives information about those signals via wait() + PT_GET_SIGINFO, then resumes the program via PT_CONTINUE.

When data=0 for PT_CONTINUE (i.e. the signal should be discarded), all signals are reported correctly.  However, when data!=0 (i.e. the signal is delivered to the program) and the signal handler is either set to SIG_IGN or to a real handler function, many of the signals are reported repeatedly to the debugger (some as many as 12 times, but all are reported at least once).

If I were to guess, I'd suspect that the repeat code is at fault.
>How-To-Repeat:
I will commit a new ATF test for it shortly.

Then:

/usr/tests/lib/libc/sys/t_ptrace_wait thread_concurrent_signals_sig_ign
>Fix:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.