From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 11110 invoked from network); 19 Jun 2022 06:14:59 -0000 Received: from tb-ob0.topicbox.com (64.147.108.117) by inbox.vuxu.org with ESMTPUTF8; 19 Jun 2022 06:14:59 -0000 Received: from tb-mx0.topicbox.com (tb-mx0.nyi.icgroup.com [10.90.30.73]) by tb-ob0.topicbox.com (Postfix) with ESMTP id 21B10244BA for ; Sun, 19 Jun 2022 02:14:58 -0400 (EDT) (envelope-from bounce.mMd81beb48e514ad6a776fa41d.r522be890-2105-11eb-b15e-8d699134e1fa@9fans.bounce.topicbox.com) Received: by tb-mx0.topicbox.com (Postfix, from userid 1132) id 23934290CA3F; Sun, 19 Jun 2022 02:14:58 -0400 (EDT) ARC-Authentication-Results: i=2; topicbox.com; arc=pass; dkim=pass (1024-bit rsa key sha256) header.d=posixcafe.org header.i=@posixcafe.org header.b=gCKToLEj header.a=rsa-sha256 header.s=20200506 x-bits=1024; dmarc=pass policy.published-domain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none (p=none,d=none,d.eval=none) policy.policy-from=p header.from=posixcafe.org; spf=pass smtp.mailfrom=moody@posixcafe.org smtp.helo=mail.posixcafe.org; x-internal-arc=fail (as.1.topicbox.com=pass, ams.1.topicbox.com=fail (message has been altered)) (Message modified while forwarding at Topicbox) ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d= topicbox.com; h=message-id:date:mime-version:subject:to :references:from:in-reply-to:content-type :content-transfer-encoding:list-help:list-id:list-post :list-subscribe:reply-to:list-unsubscribe; s=sysmsg-1; t= 1655619298; bh=SzR3QXoM0h2SnlaPJwKaI4cGkxsO1R3H4WFBvJxyzLU=; b=c BEYbneeAxF3rA6fn6aGT8KBzO84gwUVY5weZIaL8k5OxC1ym9rq+X2c9/FfWvXph NgCrN9lu9JKYautiS64WfxTkuRvQK9DXY2uHYB8VrntX2lfASD0X8VpCjNGCtEyW 6b1esbtbqyDdReoceFrB53gFy2mCEELXq/Gy0Pgzko= ARC-Seal: i=2; a=rsa-sha256; cv=pass; d=topicbox.com; s=sysmsg-1; t= 1655619298; b=o7QbBm08JLNXLTnN8yUFUs1aIEGiWxkPSo3A9iznK7YMoUEle0 FviuWWboAc3vx5XYJIRmjPZXmiifJib86jWxUehA9R3aqabeaT0Q/vwU1M+DfZrG llzCvDWH1Zsobpe9qRWYZxpGSf9zpw2i0wV8+x4udFQLRTR0mvIKJkvuM= Authentication-Results: topicbox.com; arc=pass; dkim=pass (1024-bit rsa key sha256) header.d=posixcafe.org header.i=@posixcafe.org header.b=gCKToLEj header.a=rsa-sha256 header.s=20200506 x-bits=1024; dmarc=pass policy.published-domain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none (p=none,d=none,d.eval=none) policy.policy-from=p header.from=posixcafe.org; spf=pass smtp.mailfrom=moody@posixcafe.org smtp.helo=mail.posixcafe.org; x-internal-arc=fail (as.1.topicbox.com=pass, ams.1.topicbox.com=fail (message has been altered)) (Message modified while forwarding at Topicbox) X-Received-Authentication-Results: tb-mx1.topicbox.com; arc=none (no signatures found); bimi=skipped (DMARC Policy is not at enforcement); dkim=pass (1024-bit rsa key sha256) header.d=posixcafe.org header.i=@posixcafe.org header.b=gCKToLEj header.a=rsa-sha256 header.s=20200506 x-bits=1024; dmarc=pass policy.published-domain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none (p=none,d=none,d.eval=none) policy.policy-from=p header.from=posixcafe.org; iprev=pass smtp.remote-ip=45.76.19.58 (mail.posixcafe.org); spf=pass smtp.mailfrom=moody@posixcafe.org smtp.helo=mail.posixcafe.org; x-aligned-from=pass (Address match); x-me-sender=none; x-ptr=pass smtp.helo=mail.posixcafe.org policy.ptr=mail.posixcafe.org; x-return-mx=pass header.domain=posixcafe.org policy.is_org=yes (MX Records found: mail.posixcafe.org); x-return-mx=pass smtp.domain=posixcafe.org policy.is_org=yes (MX Records found: mail.posixcafe.org); x-tls=pass smtp.version=TLSv1.2 smtp.cipher=ECDHE-RSA-AES256-GCM-SHA384 smtp.bits=256/256; x-vs=clean score=0 state=0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=9fans.net; h=message-id :date:mime-version:subject:to:references:from:in-reply-to :content-type:content-transfer-encoding:list-help:list-id :list-post:list-subscribe:reply-to:list-unsubscribe; s=dkim-1; t=1655619297; x=1655705697; bh=SENXwiHK9UVWAl5Bt1yv0XcxQQ6Vqq2l 7LMBIRWjP1A=; b=G9N9nFgAxhKPu6ClKe/hHnO6lko/YqZ8wV8OWzFbhqR47pZg UD6M7Z6nShbRJtjSQfYlm/N813LGk3+wALD8yN8I0JYpPGeEdtfWuACr6AnWsaO4 rIe/DHp4P4sPNxJKqaZdhk7bJOFEk4Qr4Yi1+XNiSGdKsY33BKxQF6KdBEk= Received: from tb-mx1.topicbox.com (localhost.local [127.0.0.1]) by tb-mx1.topicbox.com (Postfix) with ESMTP id 365001596AE6 for <9fans@9fans.net>; Sun, 19 Jun 2022 02:14:47 -0400 (EDT) (envelope-from moody@posixcafe.org) Received: from tb-mx1.topicbox.com (localhost [127.0.0.1]) by tb-mx1.topicbox.com (Authentication Milter) with ESMTP id F60841A6442; Sun, 19 Jun 2022 02:14:47 -0400 ARC-Seal: i=1; a=rsa-sha256; cv=none; d=topicbox.com; s=arcseal; t= 1655619287; b=eUjKoGTkYX3cD4WbYjbLL7D882uKRIunMcghvENV1fIlgFHvDt 4qqGk/OTeejnSK9c0p+rVq1YAV1+MsDz3UzrcmtgV+K5stLkbC3dX0ooeTosD/wk V8z5jrNlZrKHLn5xNEnEg/iV949FrcJSgalT37QnbykJlJrgh8oV3ZjWlSJ/EDU8 suoPCCI5HWwl0Qt5fj2JaChKisTuy6gteB3FU3K4EyKkvSnzJ5mswakzpbkMPMXE GQ+JWzxyDX/UsgTEYbITiawVfIBj9W6Nke+FTcgh8stBx/r+CzMRvCcNflkwmNAo 1Gi9QxP97te0KzJJMBGjUp7b7srj3ld90ZCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= topicbox.com; h=message-id:date:mime-version:subject:to :references:from:in-reply-to:content-type :content-transfer-encoding; s=arcseal; t=1655619287; bh=G19QDWJn 8+0nGJhpVckISwaUJWDD2gexSr9yO2gWy0M=; b=t8KB3SxRh1YML9/tTGomSSnb vW/iZklPZwtkjxCKOJGtx8CeRWQ/7/EqILAa/+mEZ3MXWtWXw36EQSegC4IRRXpl C+47r4V8d0tboSvYO3LmRmwZgL20MfWav8x77OycdQIXwzs0ug5k+Q5whvhzNWHU alziZ4c3KNTBqpzevAz+4W9SxZ5Hr0W/pHf15PC5lL/KmzLSoil9E7daM9AF0gMw o1s/8sv94qOvgjkwr9tx+29INpNJ129ZHvuhRwU/G3MpiScmn8BvY0wr/RQ5a+8e bVMG+hL4xadQezi+OVApRnvSBmma3szjlLnnvpJV5nS6hSNfv7qM2YoXofI/5g== ARC-Authentication-Results: i=1; tb-mx1.topicbox.com; arc=none (no signatures found); bimi=skipped (DMARC Policy is not at enforcement); dkim=pass (1024-bit rsa key sha256) header.d=posixcafe.org header.i=@posixcafe.org header.b=gCKToLEj header.a=rsa-sha256 header.s=20200506 x-bits=1024; dmarc=pass policy.published-domain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none (p=none,d=none,d.eval=none) policy.policy-from=p header.from=posixcafe.org; iprev=pass smtp.remote-ip=45.76.19.58 (mail.posixcafe.org); spf=pass smtp.mailfrom=moody@posixcafe.org smtp.helo=mail.posixcafe.org; x-aligned-from=pass (Address match); x-me-sender=none; x-ptr=pass smtp.helo=mail.posixcafe.org policy.ptr=mail.posixcafe.org; x-return-mx=pass header.domain=posixcafe.org policy.is_org=yes (MX Records found: mail.posixcafe.org); x-return-mx=pass smtp.domain=posixcafe.org policy.is_org=yes (MX Records found: mail.posixcafe.org); x-tls=pass smtp.version=TLSv1.2 smtp.cipher=ECDHE-RSA-AES256-GCM-SHA384 smtp.bits=256/256; x-vs=clean score=0 state=0 X-ME-VSCause: gggruggvucftvghtrhhoucdtuddrgedvfedruddvkedguddtfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhepkfffgg gfuffvfhfhjggtgfesthejredttdefjeenucfhrhhomheplfgrtghosgcuofhoohguhicu oehmohhougihsehpohhsihigtggrfhgvrdhorhhgqeenucggtffrrghtthgvrhhnpeegie ffiefhvddtvedvveevveffvdevgfetffehjeeiffduveduhfduheeihffgkeenucffohhm rghinhepmhgrrhgtrdhinhhfohdpthhophhitggsohigrdgtohhmnecukfhppeeghedrje eirdduledrheekpdduiedurdeljedrvddvkedrudefheenucevlhhushhtvghrufhiiigv pedtnecurfgrrhgrmhepihhnvghtpeeghedrjeeirdduledrheekpdhhvghlohepmhgrih hlrdhpohhsihigtggrfhgvrdhorhhgpdhmrghilhhfrhhomhepoehmohhougihsehpohhs ihigtggrfhgvrdhorhhgqe X-ME-VSScore: 0 X-ME-VSCategory: clean Received-SPF: pass (posixcafe.org: 45.76.19.58 is authorized to use 'moody@posixcafe.org' in 'mfrom' identity (mechanism 'mx' matched)) receiver=tb-mx1.topicbox.com; identity=mailfrom; envelope-from="moody@posixcafe.org"; helo=mail.posixcafe.org; client-ip=45.76.19.58 Received: from mail.posixcafe.org (mail.posixcafe.org [45.76.19.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tb-mx1.topicbox.com (Postfix) with ESMTPS for <9fans@9fans.net>; Sun, 19 Jun 2022 02:14:46 -0400 (EDT) (envelope-from moody@posixcafe.org) Received: from [192.168.168.200] (161-97-228-135.lpcnextlight.net [161.97.228.135]) by mail.posixcafe.org (OpenSMTPD) with ESMTPSA id 58bf1f52 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <9fans@9fans.net>; Sun, 19 Jun 2022 01:14:45 -0500 (CDT) Message-ID: <48e83724-8ea9-79b2-536a-b6d3c952c152@posixcafe.org> Date: Sun, 19 Jun 2022 00:13:50 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [9fans] syscall silently kill processes Content-Language: en-US To: 9fans@9fans.net References: <79286caa2ca77ea9b9a1cd64918bdc5f28c8f180.camel@gmail.com> <9e922645a598c69ba14b74e18e8669cc068e9717.camel@gmail.com> <0e5677e6-684d-ff37-c6cd-430d18536070@posixcafe.org> <3889a52-3fe4-c28-1c3b-a73412a489@SDF.ORG> <64a85bad-7ab-fb6-6517-acfafa819bc@SDF.ORG> <5e2f8566-da80-6c40-9718-3a9199434e7d@SDF.ORG> <55d376e1-fddb-135c-c7e3-ffca9ed621d7@posixcafe.org> From: Jacob Moody In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Topicbox-Policy-Reasoning: allow: sender is a member Topicbox-Message-UUID: 20fa3814-ef97-11ec-bf92-99742a5f789f Archived-At: =?UTF-8?B?PGh0dHBzOi8vOWZhbnMudG9waWNib3guY29tL2dyb3Vwcy85?= =?UTF-8?B?ZmFucy9UZmE2ODIzMDQ4YWQ5MGEyMS1NZDgxYmViNDhlNTE0YWQ2YTc3NmZh?= =?UTF-8?B?NDFkPg==?= List-Help: List-Id: "9fans" <9fans.9fans.net> List-Post: List-Software: Topicbox v0 List-Subscribe: Precedence: list Reply-To: 9fans <9fans@9fans.net> List-Unsubscribe: , Topicbox-Delivery-ID: 2:9fans:437d30aa-c441-11e9-8a57-d036212d11b0:522be890-2105-11eb-b15e-8d699134e1fa:Md81beb48e514ad6a776fa41d:1:PE_ZWDhg05GZrrHqx1Mm7YcjmHTTSjoPTYSlGQmwHtg On 6/18/22 23:54, adr wrote: > On Sat, 18 Jun 2022, Jacob Moody wrote: >> I've attempted to reproduce it, trying to remove the libthread/notify >> factors. I've come up with this: >> >> #include >> #include >> >> static void >> proc_udp(void*) >> { >> char resp[512]; >> char req[] =3D "request"; >> int fd; >> int n; >> int pid; >> >> fd =3D dial("udp!185.157.221.201!5678", nil, nil, nil); >> if(fd < 0) >> exits("can't dial"); >> >> if(write(fd, req, strlen(req)) !=3D strlen(req)) >> exits("can't write"); >> >> pid =3D getpid(); >> fprint(1, "start %d\n", pid); >> n =3D read(fd, resp, sizeof(resp)-1); >> fprint(1, "end %d %d\n", pid, n); >> exits(nil); >> } >> >> void >> main(int, char**) >> { >> int i; >> Waitmsg *wm; >> >> for(i =3D 0; i < 10; i++){ >> switch(fork()){ >> case -1: >> sysfatal("fork %r"); >> case 0: >> proc_udp(nil); >> sysfatal("ret"); >> default: >> break; >> } >> } >> for(i =3D 0; i < 10; i++){ >> wm =3D wait(); >> print("proc %d died with message %s\n", wm->pid, wm->msg); >> } >> exits(nil); >> } >> >> This code makes it pretty obvious that we are losing some children; >> on my machine this program never exits. I see some portion of the >> readers correctly returning -1, and the parent is able to get their >> Waitmsg but not all of them. >=20 > Moody I think this old thread will interest you: >=20 > https://marc.info/?t=3D112730920400001&r=3D1&w=3D2 >=20 > Russ Cox explained there: > It appears that your program, at its core, it is doing this: >=20 > void > readproc(void *v) > { > int fd; > char buf[100]; > fd =3D (int)v; > read(fd, buf, sizeof buf); > } >=20 > void > threadmain(int argc, char **argv) > { > int p[2]; > pipe(p); > proccreate(readproc, (void*)p[0], 8192); > proccreate(readproc, (void*)p[1], 8192); > close(p[0]); > /* and here you expect the first readproc to be done */ > close(p[1]); > /* and here the second */ > } >=20 > Each read call is holding up a reference to its channel > inside the kernel, so that even though you've closed the fd > and removed the ref from the fd table, there is still a reference > to each side of the pipe in the form of the process blocked > on the read. >=20 > I've never been sure whether the implicit ref held during > the system call is good behavior, but it's hard to change. >=20 > In your case, writing 0 (or anything) makes the read > finish, releasing the last ref to the underlying pipe when > the system call finishes, and then everything cleans up > as expected. So you've found your workaround, and now > we understand why it works. >=20 I was just making the wrong observation here. I thought I had observed the child procs getting murdered mid read, and the parent never getting the Waitmsg. Testing again I see as Andrej had observed, they are just blocking. I thought I was seeing a bug related to just udp, nothing to do with notes/threads. I apologize for the confusion, interesting thread you linked regardless. > ------------------------------------------ > 9fans: 9fans > Permalink: https://9fans.topicbox.com/groups/9fans/Tfa6823048ad90a21-M6e4= 8031f9e8673387c0b47b8 > Delivery options: https://9fans.topicbox.com/groups/9fans/subscription ------------------------------------------ 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tfa6823048ad90a21-Md81be= b48e514ad6a776fa41d Delivery options: https://9fans.topicbox.com/groups/9fans/subscription