From owner-freebsd-stable@freebsd.org Sat Aug 29 11:44:52 2015 Return-Path: Delivered-To: freebsd-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7216F9C4205 for ; Sat, 29 Aug 2015 11:44:52 +0000 (UTC) (envelope-from boland37@xs4all.nl) Received: from lb3-smtp-cloud2.xs4all.net (lb3-smtp-cloud2.xs4all.net [194.109.24.29]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (Client CN "*.xs4all.nl", Issuer "GlobalSign Domain Validation CA - SHA256 - G2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 0C9321EE7 for ; Sat, 29 Aug 2015 11:44:51 +0000 (UTC) (envelope-from boland37@xs4all.nl) Received: from charlemagne.a43.boland.org ([62.194.208.247]) by smtp-cloud2.xs4all.net with ESMTP id Abjc1r0095LoPm601bjdL0; Sat, 29 Aug 2015 13:43:39 +0200 Subject: Re: Latest stable (r287104) bash leaves zombies on exit To: Konstantin Belousov References: <63a84f64baf8768a551fc6464e8e9526@mailbox.ijs.si> <20150827162602.GJ2072@kib.kiev.ua> <55DF5C95.90502@xs4all.nl> <20150827201644.GO2072@kib.kiev.ua> <55DFFADB.2080003@xs4all.nl> <20150828100118.GR2072@kib.kiev.ua> <55E083CA.2050705@xs4all.nl> <20150828161847.GX2072@kib.kiev.ua> Cc: Mark Martinec , freebsd-stable@freebsd.org From: Michiel Boland Message-ID: <55E19AE8.9090000@xs4all.nl> Date: Sat, 29 Aug 2015 13:43:36 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150828161847.GX2072@kib.kiev.ua> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Aug 2015 11:44:52 -0000 On 08/28/2015 18:18, Konstantin Belousov wrote: > On Fri, Aug 28, 2015 at 05:52:42PM +0200, Michiel Boland wrote: >> set -e >> for a in `seq 1000` >> do >> echo -n "$a " >> xterm -e ssh nonexisting >> done >> echo "" >> >> (The idea here is that 'ssh nonexisting' should do some work and then exit, >> "xterm -e false", etc. don't appear to trigger the bug.) >> >> Prior to the patch, one of the xterms would hang after the counter reaches a >> random (reasonably small) number. >> >> After the patch the script runs till completion. > > Thank you for testing. Funny detail is that your loop does not hangs for > me, I see flapping xterms until the completion. How many cpus does your > machine have ? I have a Q8300 (4 cpus) - I guess the timing matters. Do I understand correctly that the problem is that if you install a signal handler with signal() (which is what xterm does) and pull in libthr.so somehow, then there is no thr_sighandler inserted? I condensed the xterm problem into a small C program. Compile in such a way that the delay loop does not get optimized out, and link with -lpthread. Eventually, when executed often enough, this will hang in the same fashion as xterm does. #include #include #include #include #include #include #include static void reapchild(int sig __unused) { wait(NULL); } static void delay(void) { long i, n; n = random() % 1000000; if (n < 0) { n = -n; } for (i = 0; i < n; i++) ; } int main() { int p[2]; char dummy; srandomdev(); if (signal(SIGCHLD, reapchild) == SIG_ERR) { perror("signal"); exit(1); } if (pipe(p) == -1) { perror("pipe"); exit(1); } switch (fork()) { case -1: perror("fork"); exit(1); case 0: close(p[1]); read(p[0], &dummy, 1); _exit(0); } close(p[1]); read(p[0], &dummy, 1); delay(); exit(0); } > > Below is a slightly improved version of the change, to avoid unnecessary > relocations. Would be good to rebuild the world and confirm that you > see no regression (the patch also affects rtld in some way). Ok, I will try this patch later today. Cheers, Michiel