From owner-freebsd-current@freebsd.org Fri Sep 13 14:05:37 2019 Return-Path: Delivered-To: freebsd-current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E5A4DF26A9 for ; Fri, 13 Sep 2019 14:05:37 +0000 (UTC) (envelope-from oshogbo.vx@gmail.com) Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46VHTq5MMlz3ByX for ; Fri, 13 Sep 2019 14:05:35 +0000 (UTC) (envelope-from oshogbo.vx@gmail.com) Received: by mail-pg1-f193.google.com with SMTP id u72so15303590pgb.10 for ; Fri, 13 Sep 2019 07:05:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=a0ctwTlwL0MXYKXjkQGU3EGj8KmPHjmsxjsU5sqXwAA=; b=JrDDnuT9C0cdHB31/jqFjBetXNNyi3r3xA/06a0BBLXKOQyrLcPlGGzqNxw+WqrOAN hdyTWxw+A0cQ6yDSon3UNsxSITVcGc5sDZacbIqOE0v9PP0yYq7V0YFmtbVlJV43JjnF LP5hhqwDzFl8hRZP5Ki/8jX3UtTt085FczkM5sDGv0Z7nplH8960WkSphxFYSX6ALhzb hWYVJ+zLC9smecs/fyaxmMvU/nwVVCWjVVTsp4zK+oBU0NaUEnQTBQow3lcmIzOtZogp X71HxMOOYnmot8HjQl/I/EUoQn/yOzSiW0SsUOFJ6Z7sA7tUgRxZOqlOo/LkaRFHB9Jj ipXg== X-Gm-Message-State: APjAAAWVMtiJGkSdAkSaqTHa9Rbp2mUDRGFMX9OjvQ8tnO3sOUy2s5Nh bmMrDnscgOtGVfc+/qHL96YCmaz18y0AzypO8Ec= X-Google-Smtp-Source: APXvYqwDSQU1EvYVtl7f4bMOB0WfyxP7QtP8h0P6wN2l7QYHE3Kj8CuD0VXedBPnGY5BCaoWH9v/zLiaN6kX5vhvhR4= X-Received: by 2002:a17:90a:340d:: with SMTP id o13mr5336079pjb.19.1568383533909; Fri, 13 Sep 2019 07:05:33 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Mariusz Zaborski Date: Fri, 13 Sep 2019 16:05:21 +0200 Message-ID: Subject: Re: Deadlock involving truss -f, pdfork() and wait4() To: Ryan Stone Cc: FreeBSD Current Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 46VHTq5MMlz3ByX X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of oshogbovx@gmail.com designates 209.85.215.193 as permitted sender) smtp.mailfrom=oshogbovx@gmail.com X-Spamd-Result: default: False [-3.12 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RWL_MAILSPIKE_GOOD(0.00)[193.215.85.209.rep.mailspike.net : 127.0.0.18]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-current@freebsd.org]; DMARC_NA(0.00)[freebsd.org]; MIME_TRACE(0.00)[0:+]; TO_DN_ALL(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; RCVD_IN_DNSWL_NONE(0.00)[193.215.85.209.list.dnswl.org : 127.0.5.0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; IP_SCORE(-1.12)[ipnet: 209.85.128.0/17(-3.32), asn: 15169(-2.24), country: US(-0.05)]; FORGED_SENDER(0.30)[oshogbo@freebsd.org,oshogbovx@gmail.com]; FREEMAIL_TO(0.00)[gmail.com]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; TAGGED_FROM(0.00)[]; FROM_NEQ_ENVFROM(0.00)[oshogbo@freebsd.org,oshogbovx@gmail.com]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Sep 2019 14:05:38 -0000 Hello Ryan, Can you verify is this patch fix your issue: https://reviews.freebsd.org/D20362 Thanks, Mariusz On Thu, 12 Sep 2019 at 21:37, Ryan Stone wrote: > > I've hit an issue with a simple use of pdfork(). I have a process > that calls pdfork() and the parent immediately does a wait4() on the > child pid. This works fine under normal conditions, but if the parent > is run under truss -f, the three processes deadlock. If I switch out > pdfork() for fork(), the deadlock does not occur. > > This C file demonstrates the issue: > > https://people.freebsd.org/~rstone/pdfork.c > > If I run "truss -f ./pdfork", which uses fork(), it completes within a > second. If I run "truss -f ./pdfork -p", which uses pdfork(), the > processes deadlock. If I run "./pdfork -p" without truss, it > completes normally. > > procstat reports the following kernel stacks: > > 27572 102043 truss - mi_switch+0xe2 > sleepq_catch_signals+0x425 sleepq_wait_sig+0xf _sleep+0x1bf > kern_wait6+0x695 sys_wait6+0x9f amd64_syscall+0x36e > fast_syscall_common+0x101 > 27573 102469 pdfork - mi_switch+0xe2 > sleepq_catch_signals+0x425 sleepq_wait_sig+0xf _sleep+0x1bf > kern_wait6+0x695 sys_wait4+0x78 amd64_syscall+0x36e > fast_syscall_common+0x101 > 27574 102053 pdfork - mi_switch+0xe2 > thread_suspend_switch+0xd4 ptracestop+0x13b fork_return+0x14e > fork_exit+0x83 fork_trampoline+0xe > > As near as I can tell, truss is blocked waiting for ptrace events, the > parent process is blocked in wait4, and the child process is perhaps > waiting for its parent to exit the kernel so it can send the ptrace > event? > > I really don't see anything obvious in the pdfork() code path that > would cause this to happen when fork() doesn't have the problem. It > may be that pdfork() just changes the timing enough to expose a latent > bug. > > I'm seeing this on a recentish current (r351363). > _______________________________________________ > freebsd-current@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"