zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Cebtenzzre <cebtenzzre@gmail.com>
Cc: zsh-workers@zsh.org
Subject: Re: Segmentation fault at exit with set -u and pipe
Date: Sat, 11 Feb 2023 21:31:51 -0800	[thread overview]
Message-ID: <CAH+w=7Zb-z+JdqJ2f0WziUTMO+9eKPm5z6ocjatj-bcw8r2xYA@mail.gmail.com> (raw)
In-Reply-To: <c5910bed3ba080d552a05d623f3d85c9b897ea11.camel@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 189 bytes --]

On Fri, Feb 3, 2023 at 4:32 PM Cebtenzzre <cebtenzzre@gmail.com> wrote:
>
> It appears that cleanfilelists frees memory that is
> sometimes referenced later in the exit process.

Try this.

[-- Attachment #2: cleanfilelists-bug.txt --]
[-- Type: text/plain, Size: 637 bytes --]

diff --git a/Src/jobs.c b/Src/jobs.c
index 4863962b9..59ddd952e 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -1372,8 +1372,10 @@ cleanfilelists(void)
 
     DPUTS(shell_exiting >= 0, "BUG: cleanfilelists() before exit");
  
-    for (i = 1; i <= maxjob; i++)
+    for (i = 1; i <= maxjob; i++) {
 	deletefilelist(jobtab[i].filelist, 0);
+	jobtab[i].filelist = 0;
+    }
 }
 
 /**/
@@ -1531,8 +1533,10 @@ havefiles(void)
     int i;
 
     for (i = 1; i <= maxjob; i++)
-	if (jobtab[i].stat && jobtab[i].filelist)
+	if (jobtab[i].stat && jobtab[i].filelist &&
+	    peekfirst(jobtab[i].filelist)) {
 	    return 1;
+	}
     return 0;
 
 }

  reply	other threads:[~2023-02-12  5:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-04  0:31 Cebtenzzre
2023-02-12  5:31 ` Bart Schaefer [this message]
2023-02-12 18:13   ` Cebtenzzre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7Zb-z+JdqJ2f0WziUTMO+9eKPm5z6ocjatj-bcw8r2xYA@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=cebtenzzre@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).