zsh-workers
 help / color / mirror / code / Atom feed
From: Chi Hsuan Yen <yan12125@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: zsh-workers@zsh.org
Subject: Re: Mangement of fdtable[]
Date: Fri, 16 Oct 2015 17:56:20 +0800	[thread overview]
Message-ID: <CAMNjDR0m3_a6K9dthGYhgqojWG3vLkBs1e7X0ygeHcEdfk3mMg@mail.gmail.com> (raw)
In-Reply-To: <151015172252.ZM30709@torch.brasslantern.com>

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

Dear Bart,

Thanks for digging my problem. In fact my codes uses zsocket. I think
they're similar and they actually cause the same bug. I give a TCP example
because I think it's easier to reproduce on different platforms.

In Src/Modules/socket.c, fdtable is checked but not updated. Maybe it sould
be fixed, too?

Best Regards,

Yen Chi Hsuan

On 16 October 2015 at 08:22, Bart Schaefer <schaefer@brasslantern.com>
wrote:

> 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  9:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-16  0:22 Bart Schaefer
2015-10-16  9:56 ` Chi Hsuan Yen [this message]
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=CAMNjDR0m3_a6K9dthGYhgqojWG3vLkBs1e7X0ygeHcEdfk3mMg@mail.gmail.com \
    --to=yan12125@gmail.com \
    --cc=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).