From owner-freebsd-current@freebsd.org Thu Sep 12 19:37:38 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 684A0D83AC for ; Thu, 12 Sep 2019 19:37:38 +0000 (UTC) (envelope-from rysto32@gmail.com) Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) (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 46TpvP53wmz4fn1 for ; Thu, 12 Sep 2019 19:37:37 +0000 (UTC) (envelope-from rysto32@gmail.com) Received: by mail-qk1-x72c.google.com with SMTP id u184so22809013qkd.4 for ; Thu, 12 Sep 2019 12:37:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=nBW+ufIGymAIdGqAv2jrxFR4u0H5dz8jvADK0YDjK2U=; b=rDmmqF565oSelmPNFMcZkXrbiW/t4zqBl0nessFDCL0O+XdX5srFWhf4niALdVct5b A8KtWouJUKDvT03CtpXMO937R2e0W6BespNvCR3ClPHJuv8RLlALGqQM8B5iBDRWXkvb IOhbZx05hSvgRknsH4ohjjq8mVEbLMORl4w16DklPTLo9BX8SiIglZjMWKmVrMKMeG9d KoV+xYIcjnhwsrM08jFy0VTIZUJk7FskTmh4wDIP8YUdf2bSk0O/EcVglThWedco01ej RRiVsa5HcDPyzivhHzGWSyTYZUHGHkNuPF3XFRQx54pGD6Tf+f8fVFruNL+bwhDVZhNn JdYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=nBW+ufIGymAIdGqAv2jrxFR4u0H5dz8jvADK0YDjK2U=; b=JnGd+hlkgiI7bL3huL9CXnY+B/liSLR5fKszB4InaMiERu6HmffKgsm+uOuHND67/A 8KBw/mpxBT+eKoHL/W1ep+e8wevv8IvBHwOk8bpBZraWmWTVfWRT9ZJCtbagsQ8xwelX 0mOVFItM4iD2SkDwYgqNYx/sRL+Ckfod+lBlvQcZTg8saqwADAFK9Wf90CLPEYRc9+px 81lAShDGrhV7IhE93ZhTEK7DznkHuP2IX7pWrtZxQsIJMeGn/X0fi004onY7VP+n2dFD AhlL5eHKwfFHFXk6vmo2niq5+jkB94qrZoGUYVYrmLpWLwBpaHW3qXV0KOX/DfbjDPnq nt4Q== X-Gm-Message-State: APjAAAXWQw2o+K656+VBM0V8/T402p91Jv+pwfrEsFUCRoi0NRihXgrx jEZevdarJosOqIgPwhsl0BQHPNY8uPIWiet299FcL4UG X-Google-Smtp-Source: APXvYqws6+yHBERuAnLhKZmFRpeJVJuvzgVpQQZ1p2KRyLfUhFG/ojLwMvujhykXM9D78IGYIsPOLLj2bpN1kEMnQ8k= X-Received: by 2002:a37:b045:: with SMTP id z66mr19402085qke.428.1568317056311; Thu, 12 Sep 2019 12:37:36 -0700 (PDT) MIME-Version: 1.0 From: Ryan Stone Date: Thu, 12 Sep 2019 15:37:25 -0400 Message-ID: Subject: Deadlock involving truss -f, pdfork() and wait4() To: FreeBSD Current Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 46TpvP53wmz4fn1 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=rDmmqF56; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of rysto32@gmail.com designates 2607:f8b0:4864:20::72c as permitted sender) smtp.mailfrom=rysto32@gmail.com X-Spamd-Result: default: False [-3.00 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36:c]; FREEMAIL_FROM(0.00)[gmail.com]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-current@freebsd.org]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; IP_SCORE_FREEMAIL(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; IP_SCORE(0.00)[ip: (-9.32), ipnet: 2607:f8b0::/32(-2.71), asn: 15169(-2.25), country: US(-0.05)]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCVD_IN_DNSWL_NONE(0.00)[c.2.7.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com.dwl.dnswl.org : 127.0.5.0] 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: Thu, 12 Sep 2019 19:37:38 -0000 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).