public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Fork problems on master branch
@ 2019-06-08 19:44 Ken Brown
  2019-06-09 16:51 ` Ken Brown
  0 siblings, 1 reply; 3+ messages in thread
From: Ken Brown @ 2019-06-08 19:44 UTC (permalink / raw)
  To: cygwin; +Cc: Michael Haubenwallner

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

Earlier today I reported on the cygwin-patches list a fork problem with a 
cygwin1.dll built from the master branch of the Cygwin source repo.  See 
https://cygwin.com/ml/cygwin-patches/2019-q2/msg00155.html.  A bisection showed 
that commit f03ea8e1 was the first bad commit for the problem being discussed there.

I've just run into a second fork problem for which I think the same commit is 
the first bad one.  I can't be positive, because the problem is sporadic, so I 
might have marked some bad commits as good if I didn't run the test enough times.

The test case for this (attached) is one that I used when testing my new FIFO 
code.  Normally I run this program in one terminal and type

   echo blah > /tmp/myfifo

in a second terminal.  For the present purposes, however, you can skip the 
second part and simply terminate fifo_fork_test with C-c.

In my testing, I found that running the test program would yield "read: Bad 
address" about 1 out of 10 times.  Occasionally I would get "read: Communication 
error on send" instead.  Both error messages indicate a problem with the child 
process reading from an fd inherited from the parent.

Ken

[-- Attachment #2: fifo_fork_test.c --]
[-- Type: text/plain, Size: 1071 bytes --]

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/wait.h>

int
main ()
{
  int fd;
  ssize_t nbytes;
  char buf[6];

  if (mkfifo ("/tmp/myfifo", S_IRUSR | S_IWUSR | S_IWGRP) < 0
      && errno != EEXIST)
    {
      perror ("mkfifo");
      exit (-1);
    }

  if ((fd = open ("/tmp/myfifo", O_RDWR)) < 0)
  /* if ((fd = open ("/tmp/myfifo", O_RDONLY)) < 0) */
    {
      perror ("open");
      exit (-1);
    }

  switch (fork ())
    {
    case -1:
      perror ("fork");
      exit (-1);
    case 0:			/* Child. */
      nbytes = read (fd, buf, 5);
      if (nbytes != 5)
	{
	  perror ("read");
	  exit (-1);
	}
      buf[5] = '\0';
      printf ("child read %d bytes: %s\n", nbytes, buf);
      if (close (fd) < 0)
	{
	  perror ("child close");
	  exit (-1);
	}
      exit (0);
    default:			/* Parent. */
      if (close (fd) < 0)
	{
	  perror ("parent close");
	  exit (-1);
	}
      printf ("parent waiting for child to read\n");
      wait (NULL);
      break;
    }
}

      

[-- Attachment #3: Type: text/plain, Size: 219 bytes --]


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Fork problems on master branch
  2019-06-08 19:44 Fork problems on master branch Ken Brown
@ 2019-06-09 16:51 ` Ken Brown
  2019-06-23 17:14   ` Ken Brown
  0 siblings, 1 reply; 3+ messages in thread
From: Ken Brown @ 2019-06-09 16:51 UTC (permalink / raw)
  To: cygwin

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 1666 bytes --]

On 6/8/2019 3:44 PM, Ken Brown wrote:
> Earlier today I reported on the cygwin-patches list a fork problem with a
> cygwin1.dll built from the master branch of the Cygwin source repo.  See
> https://cygwin.com/ml/cygwin-patches/2019-q2/msg00155.html.  A bisection showed
> that commit f03ea8e1 was the first bad commit for the problem being discussed there.
> 
> I've just run into a second fork problem for which I think the same commit is
> the first bad one.  I can't be positive, because the problem is sporadic, so I
> might have marked some bad commits as good if I didn't run the test enough times.
> 
> The test case for this (attached) is one that I used when testing my new FIFO
> code.  Normally I run this program in one terminal and type
> 
>     echo blah > /tmp/myfifo
> 
> in a second terminal.  For the present purposes, however, you can skip the
> second part and simply terminate fifo_fork_test with C-c.
> 
> In my testing, I found that running the test program would yield "read: Bad
> address" about 1 out of 10 times.  Occasionally I would get "read: Communication
> error on send" instead.  Both error messages indicate a problem with the child
> process reading from an fd inherited from the parent.

Never mind.  This seems to be a bug in my recently added FIFO code.  I just 
never before ran my test many times in a row, so I never saw the error before.

Sorry for the noise.

Ken
\0ТÒÐÐ¥\a&ö&ÆVÒ\a&W\x06÷'G3¢\x02\x02\x02\x02\x02\x02\x06‡GG\x03¢òö7–wv–âæ6öÒ÷\a&ö&ÆV×2æ‡FÖÀФd\x15\x13¢\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x06‡GG\x03¢òö7–wv–âæ6öÒöf\x17\x12ðФFö7VÖVçF\x17F–öã¢\x02\x02\x02\x02\x02\x02\x02\x02\x06‡GG\x03¢òö7–wv–âæ6öÒöFö72æ‡FÖÀÐ¥Vç7V'67&–&R\x06–æfó¢\x02\x02\x02\x02\x02\x06‡GG\x03¢òö7–wv–âæ6öÒöÖÂò7Vç7V'67&–&R×6–×\x06ÆPРÐ

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Fork problems on master branch
  2019-06-09 16:51 ` Ken Brown
@ 2019-06-23 17:14   ` Ken Brown
  0 siblings, 0 replies; 3+ messages in thread
From: Ken Brown @ 2019-06-23 17:14 UTC (permalink / raw)
  To: cygwin

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 917 bytes --]

On 6/9/2019 12:51 PM, Ken Brown wrote:
> On 6/8/2019 3:44 PM, Ken Brown wrote:
>> In my testing, I found that running the test program would yield "read: Bad
>> address" about 1 out of 10 times.  Occasionally I would get "read: Communication
>> error on send" instead.  Both error messages indicate a problem with the child
>> process reading from an fd inherited from the parent.
> 
> Never mind.  This seems to be a bug in my recently added FIFO code.  I just
> never before ran my test many times in a row, so I never saw the error before.

For the record, I've just pushed what I think is a fix for this problem.  (At 
least I can't reproduce the problem any more.)

Ken
\x03B‹KCB”\x1c›Ø›\x19[H\x1c™\^[ܝ\x1cΈ\b\b\b\b\b\b\x1a\x1d\x1d\x1c\x0e‹ËØÞYÝÚ[‹˜ÛÛKÜ\x1c›Ø›\x19[\Ëš\x1d^[[\x03B‘TNˆ\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\x1a\x1d\x1d\x1c\x0e‹ËØÞYÝÚ[‹˜ÛÛKÙ˜\KÃB‘^[ØÝ[Y[\x18]\x1a[ÛŽˆ\b\b\b\b\b\b\b\b\x1a\x1d\x1d\x1c\x0e‹ËØÞYÝÚ[‹˜ÛÛKÙ^[ØÜËš\x1d^[[\x03B•[œÝXœØÜšX™H\x1a[™›Îˆ\b\b\b\b\b\x1a\x1d\x1d\x1c\x0e‹ËØÞYÝÚ[‹˜ÛÛKÛ[\vÈÝ[œÝXœØÜšX™K\Ú[\^[\x19CBƒB

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-23 17:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-08 19:44 Fork problems on master branch Ken Brown
2019-06-09 16:51 ` Ken Brown
2019-06-23 17:14   ` Ken Brown

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 read-only IMAP folder(s) and NNTP newsgroup(s).