bugThe GNU Hurd - Bugs: bug #48372, read with size 0 from fifo blocks

 
 

bug #48372: read with size 0 from fifo blocks

Submitter:  Kalle Olavi Niemitalo <kon>
Submitted:  Fri 01 Jul 2016 10:00:01 PM UTC
 
Category:  Hurd Servers Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Standard Compliance
Status:  None Privacy:  Public
Assigned to:  None Originator Name: 
Open/Closed:  Open Reproducibility:  Every Time
Size (loc):  None Planned Release:  None
Effort:  0.00
Wiki-like text discussion box: 
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       No canned response available

 

Thu 07 Jul 2016 07:50:18 PM UTC, comment #5: 

I patched libpipe/pipe.c (pipe_recv) as described in comment #4, and the perl test case in the original submission no longer hangs.  Neither does a similar test with /hurd/new-fifo.

I also ran the test suite of vim-7.4.1829 with this patch and a few others, and it passed.

Is there a test case for the pflocal problem mentioned in comment #2?

Kalle Olavi Niemitalo <kon>
Wed 06 Jul 2016 04:04:24 PM UTC, comment #4: 

IEEE Std 1003.1, 2013 Edition makes nbyte==0 a special case in the read and pread functions, but I don't see similar special cases in the recv, recvfrom, and recvmsg functions.  AFAICT, those should consume the message from a message-based socket even if the buffer has zero length, unless MSG_PEEK is specified.

pflocal/io.c (S_io_read) calls pipe_read, which calls pipe_recv (pipe, noblock, 0, source, data, data_len, amount, 0,0,0,0).

pflocal/socket.c (S_socket_recv) calls pipe_recv (..., control, control_len, ports, num_ports).  In hurd/socket.defs (socket_recv), those correspond to output parameters, so I believe they are not included in the request message and the mig-generated code will ensure that e.g. control != NULL.

I think pipe_read should then apply the shortcut behavior only if (amount == 0 && data_only).  That way, the change would not affect recv, recvfrom, and recvmsg.

Kalle Olavi Niemitalo <kon>
Mon 04 Jul 2016 11:37:16 PM UTC, comment #3: 
Richard Braun <rbraun>
Project Member
Mon 04 Jul 2016 08:51:23 PM UTC, comment #2: 

It seems fine to me to fix it in libpipe (that'd fix pflocal's behavior too).

Samuel Thibault <sthibaul>
Project Administrator
Fri 01 Jul 2016 10:15:36 PM UTC, comment #1: 

/hurd/new-fifo has the same problem.

Kalle Olavi Niemitalo <kon>
Fri 01 Jul 2016 10:00:01 PM UTC, original submission:  

mkfifo da; sleep 1000 > da & rpctrace perl -e 'sysread STDIN, $_, 0' < da

hangs at:  136<--159(pid1132)->io_read (-1 0)

According to antrik, POSIX specifies that read with nbyte==0 must immediately return 0 or return an error. This could be implemented in libc, libtrivfs, fifo, or libpipe. It seems best to implement this in fifo or libpipe so that fifo can still return EBADF if the fifo was not opened for reading.

I filed this as distinct from bug 48371 (for the streamio translator) because they can be fixed and tested independently.

Kalle Olavi Niemitalo <kon>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rbraun (Posted a comment)
  • -email is unavailable- added by sthibaul (Posted a comment)
  • -email is unavailable- added by kon (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

     

     

     

    No changes have been made to this item

    Back to the top


    Powered by Savane 3.9