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

 
 

bug #48372: read with size 0 from fifo blocks

Submitted by:  Kalle Olavi Niemitalo <kon>
Submitted on:  Fri 01 Jul 2016 10:00:01 PM UTC  
 
Category: Hurd ServersSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Standard Compliance
Status: NonePrivacy: Public
Assigned to: NoneOriginator Name: 
Open/Closed: OpenReproducibility: Every Time
Size (loc): NonePlanned Release: None
Effort: 0.00
Wiki-like text discussion box: 

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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:

See http://git.savannah.gnu.org/cgit/hurd/hurd.git/commit/?id=293e86998748bae2d7a8179ad198ec3452f0d472

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 Member
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 File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    No Changes Have Been Made to This Item

    Back to the top


    Powered by Savane 3.1-cleanup1