Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Mangement of fdtable[]
- X-seq: zsh-workers 36874
- From: Chi Hsuan Yen <yan12125@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Mangement of fdtable[]
- Date: Fri, 16 Oct 2015 17:56:20 +0800
- Cc: zsh-workers@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=z5BpdKwc6eMxrV1XPOKlSk4fsX6C0loAKhbRy/mbOSw=; b=cgciJsXxLG7RfbayLg9+cJ32HUBIXYn/KNWDU1rToBx0wM4n2OROoRuCUOxmbVOGAR LdyKnNRs0YY1AkrD+GciJZoMwBNmBUD6PAL8Gso1S5PctF8REpkts3SsnLprQVkscHOM Hvha/GpNLDc5usO0lZNJeuK5akmo9xqnwzOKC1pHEC8q9mjpF+P9TM4ev5yZpkGSel3J XzyLhD3Ow8hQJxlAhqlB8n7JVKh8dJ27K2g2pBptCVOr38O8J9WP5WEEkrQrKJV85lMp aS2pqGckhLh+VVJ8TJOBjKY+J0Fmm101vLeaekBa8icbP+YS/z4lVjqfGeQrOgf9WLVk n6xg==
- In-reply-to: <151015172252.ZM30709@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <151015172252.ZM30709@torch.brasslantern.com>
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@xxxxxxxxxxxxxxxx>
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
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author