zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: A05 test failure (was Re: 5.0.9 eventually...?)
Date: Mon, 10 Aug 2015 10:24:56 -0700	[thread overview]
Message-ID: <150810102456.ZM5834@torch.brasslantern.com> (raw)
In-Reply-To: <loom.20150810T091202-541@post.gmane.org>

On Aug 10,  7:12am, Ismail Donmez wrote:
}
} latest git started to fail here on Linux x64:
} 
} ./A05execution.ztst: starting.
} This test takes 5 seconds to fail...
} Test ./A05execution.ztst failed: bad status 2, expected 1 from:
} Was testing: The status of recently exited background jobs is recorded

This apparently has always been a race condition and queuing of signals
in more places simply made it obvious.  I can only reproduce the failed
test on one of the systems where I can try it.

What's happening is that the SIGCHLD for (exit 2) is arriving during the
run of zhandler() for recording the status of (exit 1).  The value of
the global lastval2 is not saved/restored around the signal handling
so when the (exit 1) handler resumes it copies the exit status of the
second child into the bgstatus list as the exit of the first child.

It's fairly easy to make any two of the jobs exchange status by adding
sleep or other delays.

Anyway, turns out this was an ANCIENT bug that the revised queueing
paradigm exposed.

diff --git a/Src/signals.c b/Src/signals.c
index 697c4c5..acdc0bc 100644
--- a/Src/signals.c
+++ b/Src/signals.c
@@ -487,6 +487,12 @@ wait_for_processes(void)
 	    break;
 	}
 
+	/* This is necessary to be sure queueing_enabled > 0 when
+	 * we enter printjob() from update_job(), so that we don't
+	 * decrement to zero in should_report_time() and improperly
+	 * run other handlers in the middle of processing this one */
+	queue_signals();
+
 	/*
 	 * Find the process and job containing this pid and
 	 * update it.
@@ -530,6 +536,8 @@ wait_for_processes(void)
 	if (jn && !(jn->stat & (STAT_CURSH|STAT_BUILTIN)) &&
 	    jn - jobtab != thisjob)
 	    addbgstatus(pid, (int)lastval2);
+
+	unqueue_signals();
     }
 }
 

-- 
Barton E. Schaefer


  parent reply	other threads:[~2015-08-10 17:25 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-08 19:05 5.0.9 eventually...? Peter Stephenson
2015-08-08 20:40 ` Bart Schaefer
2015-08-08 20:50   ` Mikael Magnusson
2015-08-09  0:20     ` Bart Schaefer
2015-08-08 21:22 ` Oliver Kiddle
2015-08-09  0:23   ` Bart Schaefer
2015-08-09  0:24     ` Bart Schaefer
2015-08-09 14:45       ` Jun T.
2015-08-09 16:15         ` Completion after assignment as command (Re: 5.0.9 eventually...?) Peter Stephenson
2015-08-10  7:12 ` 5.0.9 eventually...? Ismail Donmez
2015-08-10  9:59   ` Ismail Donmez
2015-08-10 12:50   ` Wait test failure Peter Stephenson
2015-08-10 15:18     ` Peter Stephenson
2015-08-10 15:48       ` Peter Stephenson
2015-08-10 17:44         ` Bart Schaefer
2015-08-10 19:11           ` Peter Stephenson
2015-08-10 17:24   ` Bart Schaefer [this message]
2015-08-11  8:20     ` A05 test failure (was Re: 5.0.9 eventually...?) Ismail Donmez
2015-08-17 19:54 ` 5.0.9 eventually...? Peter Stephenson
2015-08-17 20:08   ` Bart Schaefer
2015-08-17 21:17   ` Mikael Magnusson

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=150810102456.ZM5834@torch.brasslantern.com \
    --to=schaefer@brasslantern.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).