zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Mangement of fdtable[]
Date: Thu, 15 Oct 2015 17:22:52 -0700	[thread overview]
Message-ID: <151015172252.ZM30709@torch.brasslantern.com> (raw)

I was puzzling over Yen Chi Hsuan's bug report in 36866 so was looking
through tcp.c and noticed that it opens file descriptors with socket()
without marking them used in fdtable[].  The only time they're handled
"properly" is with "ztcp -l" which makes a movefd() call.

I think this means some fds may be closed in some cases they shouldn't,
or conversely left open in cases they shouldn't.  This may apply to fds
in other modules, e.g., the descriptor from gdbm_open() in db_gdbm.c.

This further led me to notice that when descriptors are manipulated in
utils.c, it carefully calls the static check_fd_table() function every
time to be sure the descriptor has a slot in the table before an FDT_*
value is poked for it.  Other parts of the code (mostly exec.c) simply
reference fdtable[N] without error checking.

I guess this is OK because fdtable[] is allocated zopenmax() slots in
zsh_main(), but it seems inconsistent if not actually wrong.

Comments?

-- 
Barton E. Schaefer


             reply	other threads:[~2015-10-16  0:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-16  0:22 Bart Schaefer [this message]
2015-10-16  9:56 ` Chi Hsuan Yen
2015-10-16 19:44 ` Peter Stephenson
2015-10-24 18:16 ` Peter Stephenson
2015-10-24 18:43   ` Bart Schaefer
2015-10-24 19:14     ` Peter Stephenson
2015-10-24 19:37       ` Bart Schaefer
2015-10-24 19:43       ` Peter Stephenson
2015-10-24 21:05         ` Bart Schaefer
2015-10-25 18:44           ` Peter Stephenson
2015-10-26  1:15             ` Bart Schaefer

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=151015172252.ZM30709@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).