zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: Nicolas Cavigneaux <bounga@altern.org>,
	zsh-workers@sunsite.dk (Zsh hackers list)
Subject: Re: Job table full
Date: Tue, 25 May 2004 19:19:24 +0100	[thread overview]
Message-ID: <200405251819.i4PIJOTL007015@news01.csr.com> (raw)
In-Reply-To: "Wayne Davison"'s message of "Tue, 25 May 2004 10:56:05 PDT." <20040525175605.GD7832@blorf.net>

Wayne Davison wrote:
> On Wed, May 12, 2004 at 02:40:29PM +0100, Peter Stephenson wrote:
> > A reliable way of reproducing it would help.
> 
> It's pretty easy:
> 
>     zsh -f
>     preexec() { x=`echo hi` }
>     sleep 1 &
>     :              [execute any 20 commands]
> 
> The problem appears to be that, after the job-control run, the value of
> "thisjob" in the preexec() function becomes -1.  This comparison then
> fails due to a signed/unsigned mismatch:
> 
>     if (thisjob >= jobtabsize - 1 && !expandjobtab()) {

Aha.  That's good.

thisjob is allowed to be -1, it simply means there's no valid
current job.  So the-test-that-no-one-understands should simply have
`thisjob != -1' in it, as in other places in the code.

Here is a fix with some other paranoid tests for thisjob when debugging
is turned on.

Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.62
diff -u -r1.62 exec.c
--- Src/exec.c	21 May 2004 11:19:30 -0000	1.62
+++ Src/exec.c	25 May 2004 18:18:06 -0000
@@ -219,7 +219,7 @@
     /*
      * Is anybody willing to explain this test?
      */
-    if (thisjob >= jobtabsize - 1 && !expandjobtab()) {
+    if (thisjob != -1 && thisjob >= jobtabsize - 1 && !expandjobtab()) {
 	zerr("job table full", NULL, 0);
 	return -1;
     }
Index: Src/jobs.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/jobs.c,v
retrieving revision 1.28
diff -u -r1.28 jobs.c
--- Src/jobs.c	2 May 2004 19:55:58 -0000	1.28
+++ Src/jobs.c	25 May 2004 18:18:07 -0000
@@ -904,6 +904,7 @@
     Process pn, *pnlist;
     struct timezone dummy_tz;
 
+    DPUTS(thisjob == -1, "No valid job in addproc.");
     pn = (Process) zshcalloc(sizeof *pn);
     pn->pid = pid;
     if (text)
@@ -1035,6 +1036,7 @@
 waitjobs(void)
 {
     Job jn = jobtab + thisjob;
+    DPUTS(thisjob == -1, "No valid job in waitjobs.");
 
     if (jn->procs || jn->auxprocs)
 	zwaitjob(thisjob, 0);
@@ -1129,6 +1131,7 @@
 {
     Process pn;
 
+    DPUTS(thisjob == -1, "No valid job in spawnjob.");
     /* if we are not in a subshell */
     if (!subsh) {
 	if (curjob == -1 || !(jobtab[curjob].stat & STAT_STOPPED)) {

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


       reply	other threads:[~2004-05-25 18:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20040525175605.GD7832@blorf.net>
2004-05-25 18:19 ` Peter Stephenson [this message]
2004-05-25 18:47   ` Wayne Davison
1999-07-04  8:07 job " Tanaka Akira
1999-07-04 12:48 ` Peter Stephenson

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=200405251819.i4PIJOTL007015@news01.csr.com \
    --to=pws@csr.com \
    --cc=bounga@altern.org \
    --cc=zsh-workers@sunsite.dk \
    /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).