From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27816 invoked from network); 9 Mar 2009 15:50:17 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 9 Mar 2009 15:50:17 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 61795 invoked from network); 9 Mar 2009 15:50:13 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 9 Mar 2009 15:50:13 -0000 Received: (qmail 1953 invoked by alias); 9 Mar 2009 15:50:07 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 26703 Received: (qmail 1941 invoked from network); 9 Mar 2009 15:50:07 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 9 Mar 2009 15:50:07 -0000 Received: from vms173007pub.verizon.net (vms173007pub.verizon.net [206.46.173.7]) by bifrost.dotsrc.org (Postfix) with ESMTP id 5191480307F8 for ; Mon, 9 Mar 2009 16:50:03 +0100 (CET) Received: from torch.brasslantern.com ([96.249.201.13]) by vms173007.mailsrvcs.net (Sun Java(tm) System Messaging Server 6.3-7.04 (built Sep 26 2008; 32bit)) with ESMTPA id <0KG800G4HXAPRLGG@vms173007.mailsrvcs.net> for zsh-workers@sunsite.dk; Mon, 09 Mar 2009 10:49:44 -0500 (CDT) Received: from torch.brasslantern.com (localhost.localdomain [127.0.0.1]) by torch.brasslantern.com (8.13.1/8.13.1) with ESMTP id n29FnaYc027148 for ; Mon, 09 Mar 2009 08:49:37 -0700 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id n29Fnaig027147 for zsh-workers@sunsite.dk; Mon, 09 Mar 2009 08:49:36 -0700 From: Bart Schaefer Message-id: <090309084936.ZM27146@torch.brasslantern.com> Date: Mon, 09 Mar 2009 08:49:36 -0700 In-reply-to: <17095.1236597765@csr.com> Comments: In reply to Peter Stephenson "PATCH: Seg. fault in chpwd hook in a widget" (Mar 9, 11:22am) References: <17095.1236597765@csr.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@sunsite.dk (Zsh hackers list) Subject: Re: PATCH: Seg. fault in chpwd hook in a widget MIME-version: 1.0 Content-type: text/plain; charset=us-ascii X-Virus-Scanned: ClamAV 0.92.1/9080/Fri Mar 6 20:13:38 2009 on bifrost X-Virus-Status: Clean On Mar 9, 11:22am, Peter Stephenson wrote: } Subject: PATCH: Seg. fault in chpwd hook in a widget } } Just had a look at the Sourforge bug tracker, which normally I don't } have time to do (please feel free to forward things to the list if you } notice anything there which appears to be reproducible and hasn't been } fixed); issue 2338948 is this: This was originally on zsh-workers, thread starting at 26089. You even answered with a patch in 26091, which was applied 2008-11-25 or so says the ChangeLog, but you followed *that* by saying it might need deeper inspection. } This is an interesting interaction of different levels of the shell. I } think a key part of it is the "source". It seems that hbegin() in here } is trashing the current history line chline. It seems to me that we } should only be calling hbegin() after a lexsave(), to protect against } this, and there appears to be nothing in the call to loop() from } source() that does that. I think you're right about lexsave(), although history has never really been my bit of the code [to the extent that I "have" any bit at all]. Wayne may have some input. } I'm quite surpsised we've never seen anything like this before; there } seems to be no protection against chline being trashed by any old } "source" or "." that comes along. As far as I can see, lexsave() is the } only way of doing this. I think the answer is that most of the time the } history mechanism has exited by this time, so chline is already NULL and } its friends aren't being used. So why *hasn't* the history mechanism exited by the time chpwd is called? Aha; it's not direclty because of "source", it's because he's calling "cd" from inside a ZLE widget. The hooks are invoked in a context from which they were never meant to be invoked. So your lexsave()/lexrestore() is probably the correct thing, but there may be other consequences of hook/widget interaction still waiting to bite us for other hooks. } Obviously any alternative opinions would be useful. Currently that } means Bart, but both of us would be very interested in getting new } apprentice source code gurus... Leak some of that sentiment onto zsh-users. Maybe potential apprentices just aren't reading -workers.