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=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 4103 invoked from network); 13 Apr 2023 13:20:10 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 13 Apr 2023 13:20:10 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1681392010; b=GtTzwsjou6CQFVHvAtePd89ZS9usQXH0wlFpbTb9Qigx1Jm2JTYZw/tIIT8ifmQNiOotFaNQSR sWPfXXRPLY0zGTQteEuUTwOMu8VS5OFkBI8YEm2tMr6JkLqh84AUYsCccYv2enk7yJYlVHLrfK MtzyADRvitg8moorJpUK8pOI94nSNBKwGNAFFrJlIB7aFOrZUzBactPpwFHqw7cOWFOsxQhYvh LXAiyeRh5t3sUoX9Kr/Y4ghOoW6GOEf8B1R9NcVnGcee66iQmE+BBX231BPQWTAL0X2AUG1MfU mLhhxIHmUtaD6VRvwNGmkhLUW5CGyH6RSGmBPrJ8g13v6A==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (smtpq2.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.97; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1681392010; bh=+ohI3TwQDg7PPYjEGJN1O6tBbzrmiBfvxeDR5JAtMBg=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject: References:In-Reply-To:Message-ID:To:From:Date:DKIM-Signature: DKIM-Signature; b=dTwR2AMxJzgN8IANiXVDb46CBdieZpasC8GOCmyIMASGjTUadSw24rkoePQi/WIKX0lEti/D60 P2xlmUZI54IgDRTkO5+o8PsQ94k2lnWE8PYc5hJU2vvipHq8PExX0ld1P/E/PaCLBcT/nr1/3v dET9T+mY5CpPEf8DwPQo3XGcyK/DP0d6kK2zU1KLdoVh7WdICroWsdjh9CQi60wFvB0sk76SGG eRCbmBI8xF/z8BtytuisHdlJnjYVmpaSqMcQLOozdeVJ+00WcMnsFXtKqihqbc3utGbjgqk4fy AYa3mukIyLtCdxsLUdt/xX6XPGMng+Jw1Gj0o6VoCXMz1w==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:References:In-Reply-To:Message-ID:To:From: Date:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=J5vNFIh+UHFvhTgvL6Msm7PX7Az2N5oOIH0zn+PDvU8=; b=BbwgRPs7tj8L0QWRb9jHC+F2Bt RMOSWUQfxjeSymVbAVLiH4Xv5MLs505BMHvU9XMFScwvgNClDsAOm3Fyh2tBl3T2DxNnq6sCewAHi ntRVXXGf9hsL2Ci91YdCjGNWOvnkCslBbXcZ9VXVF72VR74QVbF6IvcfBlm4A35dq8Abho8RqePdP F0BjKCCykC3ivoJQMxCVxy+4PW4/ReAyOQEA7sOZoVwE1px5ptaaElc4s8hmpqipqS+YJzelIMRbi oCprdCXw4EW30hbtY/EmVjE9fyFBlZVrAYaP7nrfO13iJUEVhTC2hYM/ZNvUlfXmZzso7XKcY+7IY vVCEBmKA==; Received: by zero.zsh.org with local id 1pmwry-000Oa7-DD; Thu, 13 Apr 2023 13:20:10 +0000 Authentication-Results: zsh.org; iprev=pass (smtpq2.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.97; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none Received: from smtpq2.tb.ukmail.iss.as9143.net ([212.54.57.97]:48772) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1pmwrB-000OEB-RR; Thu, 13 Apr 2023 13:19:23 +0000 Received: from [212.54.57.81] (helo=smtp2.tb.ukmail.iss.as9143.net) by smtpq2.tb.ukmail.iss.as9143.net with esmtp (Exim 4.90_1) (envelope-from ) id 1pmwrB-0004gj-4p for zsh-workers@zsh.org; Thu, 13 Apr 2023 15:19:21 +0200 Received: from oxbe10.tb.ukmail.iss.as9143.net ([172.25.160.141]) by smtp2.tb.ukmail.iss.as9143.net with ESMTP id mwrBpDOeUfELJmwrBp7U6p; Thu, 13 Apr 2023 15:19:21 +0200 X-Env-Mailfrom: p.w.stephenson@ntlworld.com X-Env-Rcptto: zsh-workers@zsh.org X-SourceIP: 172.25.160.141 X-CNFS-Analysis: v=2.4 cv=dqIdSXs4 c=1 sm=1 tr=0 ts=64380159 cx=a_exe a=f70ZRucvQZHi2l2hbwz5vQ==:117 a=wbvTLvLwOfMA:10 a=IkcTkHD0fZMA:10 a=NLZqzBF-AAAA:8 a=mJjsAB42_tJU-7ePrNYA:9 a=QEXdDO2ut3YA:10 a=RchoEgWomvYJfgJ0MydD:22 X-Authenticated-Sender: p.w.stephenson@ntlworld.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ntlworld.com; s=meg.feb2017; t=1681391961; bh=+ohI3TwQDg7PPYjEGJN1O6tBbzrmiBfvxeDR5JAtMBg=; h=Date:From:To:In-Reply-To:References:Subject; b=U5YFeHgnkvBPRilRWO4UrHQhstLncKXpJlvkOSRYMgR8VhPmKz2t1tdMMBG00llOF zbS1oOiu0FNlrwqismYmgN7XE5M9X3TD5yFtJ6gsWOKXzdmu3QCzC6qQKFPppheyp8 82NQQ3SJ6IUYSbYq9ArkC1d0fQ72paBGcpL+QdL/etGV47p65ou8YiT9EdOSji/k8y 99rAECXk4eALiR4tUUD8nV3+HM7MdQBFlcfeKhGLZYpvF0K1hCPOZSuLGVee4AOnVU x1xXf0rUHbF2Pv1zphq+ZUYYEjGYujkwfrqElK9zeuEM5kBxEQ+KVKbujH7H/00SaL n4NPMbWSYagOw== Date: Thu, 13 Apr 2023 14:19:21 +0100 (BST) From: Peter Stephenson To: zsh-workers@zsh.org Message-ID: <1865187346.2010280.1681391961060@mail.virginmedia.com> In-Reply-To: <78EBC2C7-5645-4D35-B285-F140228D444C@kba.biglobe.ne.jp> References: <48A7DCE2-AEC1-4777-949C-50917EDCECB1@kba.biglobe.ne.jp> <5C4788C8-4E40-4565-AFE8-84D57949BC8C@ntlworld.com> <267594676.4158370.1681382869709@mail.virginmedia.com> <1621107110.4161180.1681384345108@mail.virginmedia.com> <78EBC2C7-5645-4D35-B285-F140228D444C@kba.biglobe.ne.jp> Subject: Re: Probabilistic crash on zsh 5.9 on x86_64 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Priority: 3 Importance: Normal X-Mailer: Open-Xchange Mailer X-Originating-IP: 147.161.167.85 X-Originating-Client: open-xchange-appsuite X-CMAE-Envelope: MS4xfNBsOxAzAjDZs62EX7xnLqDncuu15RNLh8afhWEtPBM4AD/uYJVesmz9atYJOd4alI9EwuQUSZfiNfauGbqBGo7WkYu6jqzm35UEHjaxx4m037CICbiH oA4d2+Bye51iMNxIc8Jw/dcPLC+yRmjFcPQQRFrhqNtq7WAACWQ+qsOnfr1WQuvrIlpxCGThi3qZvu2jNixDzRa29vk7RzlG/Nlp7UUG2iCCB5g0wocqvFHW X-Seq: 51647 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: > On 13/04/2023 14:02 Jun. T wrote: > > 2023/04/13 20:12=E3=80=81Peter Stephenson = =E3=81=AE=E3=83=A1=E3=83=BC=E3=83=AB: > > "watch" says the real culprit is this unsettrap() in starttrapscope(). > > I guess the save and restore action here needs a corresponding > > useeprog / freeprog, not sure the best way of doing that yet. >=20 > As I wrote before, the entire 'struct shfunc' is freed by > shfunctab->freenode(shf) (signals.c:982), or freeshfuncnode(shf). > I think it is not just the problem of the reference count of Eprog > (shfnc.funcdef.nref). > Or maybe I misunderstood your post. "Freeing" really means reducing the reference count and then actually freeing the structure only when the reference count hits zero. So because we want to keep this structure, the reference count shouldn't be zero at this point (it shouldn't ever be allowed to go to zero for a permanently allocated structure visible to user code, hence the DPUTS test), and if it isn't then the problem goes away --- this becomes just a normal function call. However, it's not trivial because of the way we save and restore TRAPEXIT (and possibly other traps). We do this because the TRAPEXIT shouldn't be running from within a nested function call. So what we should logically do is take the code chunk out of the trap list but marked in such a way that it won't get actually freed, because we're going to put it back again later, and because someone may access the same structure meanwhile (as it's permanently allocated --- the whole point of reference counts being that it's hard to know for sure who's referring to which code chunk at any given time). Unfortunately, it looks like this process is more complicated than that, involving actual copies, so finding a place to bump the reference count and then later reduce it again (which would free the structure if it actually wasn't needed any more at that second point) isn't trivial, and it's quite possible there is another solution not involving reference counts. Hope that's clearer but I'm not sure it is... pws