zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Martijn Dekker <martijn@inlv.org>,
	Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [BUG] Solaris-specific program flow corruption after subshell error exit
Date: Sun, 26 Feb 2017 12:29:19 -0800	[thread overview]
Message-ID: <170226122919.ZM4443@torch.brasslantern.com> (raw)
In-Reply-To: <5258197e-1903-b188-f033-fc424a271077@inlv.org>

On Feb 26,  6:36am, Martijn Dekker wrote:
}
} In the course of that testing I've come across a zsh bug that *only*
} manifests on Solaris, at least version 11.3. (A free VirtualBox VM for
} evaluation purposes is available from Oracle.)
} 
} If a subshell exits due to an error in a special builtin or redirection,
} execution flow is corrupted in such a manner that, when end of file is
} reached without an explicit 'return' or 'exit' being encountered,
} execution of the file does not end but restarts at the point exactly
} after the subshell was exited. The second time around, if program
} specifics allow it, execution ends normally.

Given that this is specific to Solaris and has to do with execution of
script files, I'm going to guess that it's related to file descriptor
management and buffering within STREAMS modules.

In particular I'm guessing that the POSIX-compatible behavior referenced
at the "fatal:" label in exec.c near line 4000 is leaving some kind of
shared stdin state between the parent and the subshell, because "set"
is a special builtin so will invoke the exit at that point.  Without
actually running the code, I'd expect we're going through the _exit()
branch rather than the exit() branch which under normal circumstances is
deliberately to avoid having such shared state mess up the parent file
descriptor positions, but maybe that's not sufficient.

Whether this is revealing a bug in zsh or a bug in Solaris 11.3 I can't
say.


  reply	other threads:[~2017-02-26 20:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-26  5:36 Martijn Dekker
2017-02-26 20:29 ` Bart Schaefer [this message]
2017-02-26 22:55   ` Martijn Dekker
2017-02-27  7:39     ` Bart Schaefer
2017-02-27 14:00       ` Martijn Dekker
2017-07-05  1:37         ` Martijn Dekker

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=170226122919.ZM4443@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=martijn@inlv.org \
    --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).