From: "Lu, Hongjiu" <hongjiu.lu@intel.com>
To: "Andrew Morton" <akpm@osdl.org>, "Zou, Nanhai" <nanhai.zou@intel.com>
Cc: <linux-kernel@vger.kernel.org>
Subject: RE: [Patch] Fix a race condition in pty.c
Date: Fri, 17 Dec 2004 09:09:15 -0800 [thread overview]
Message-ID: <CBDB88BFD06F7F408399DBCF8776B3DC0322102A@scsmsx403.amr.corp.intel.com> (raw)
Sorry I didn't mention that my testcase hang:
11540 pts/0 S 0:00 ./pty
11541 ? Zs 0:00 [true] <defunct>
Both parent and child are sleeping. They will never wake up. I updated
my bug report
http://bugzilla.kernel.org/show_bug.cgi?id=3894
with the config file for P4 SMP machine.
H.J. Lu
Intel Corporation
>-----Original Message-----
>From: Andrew Morton [mailto:akpm@osdl.org]
>Sent: Friday, December 17, 2004 12:36 AM
>To: Zou, Nanhai
>Cc: linux-kernel@vger.kernel.org; Lu, Hongjiu
>Subject: Re: [Patch] Fix a race condition in pty.c
>
>"Zou, Nanhai" <nanhai.zou@intel.com> wrote:
>>
>> <<pty_close-race-fix.patch>> There is a race condition int pty.c
>> when pty_close wakes up waiter on its pair device before set
>> TTY_OTHER_CLOSED flag.
>>
>> It is possible on SMP or preempt kernel, waiter wakes up too early
>that
>> it will not get TTY_OTHER_CLOSED flag then fall into sleep again.
>>
>> Lu hong jiu report this bug will hang some expect scripts on SMP
>> machines.
>
>The patch looks good (apart from the application/octet-stream encoding.
>grr.)
>
>But on my test box it still doesn't fix the testcase which hj attached
>to
>bug 3894:
>
>select (3) returns: 1
>Read -1 characters.
>errno: Input/output error
>334
>select (3) returns: 1
>Read -1 characters.
>errno: Input/output error
>335
>
>In fact the same happens on a non-preempt uniprocessor kernel, so I
>must be
>seeing something different.
>
>#include <sys/types.h>
>#include <sys/select.h>
>#include <stdio.h>
>#include <unistd.h>
>#include <pty.h>
>
>int
>main ()
>{
> pid_t pid;
> int fd;
> char slave_name [20];
> char buffer [1000];
> int count;
> fd_set readfds;
> int ret;
>
> pid = forkpty (&fd, slave_name, NULL, NULL);
> switch (pid)
> {
> case 0: /* Child process. */
> if (execlp ("true", "true", NULL))
> perror ("execlp");
> return 1;
> break;
>
> default: /* Parent process. */
> break;
> }
>
> FD_ZERO (&readfds);
> FD_SET (fd, &readfds);
> ret = select (1024, &readfds, NULL, NULL, NULL);
> printf ("select (%d) returns: %d\n", fd, ret);
> if (ret < 0)
> perror ("select");
> else if (FD_ISSET (fd, &readfds))
> {
> count = read (fd, buffer, 999);
> printf ("Read %d characters.\n", count);
> perror("errno");
> }
> return 0;
>}
next reply other threads:[~2004-12-17 17:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-17 17:09 Lu, Hongjiu [this message]
-- strict thread matches above, loose matches on Subject: below --
2004-12-17 3:07 Zou, Nanhai
2004-12-17 8:35 ` Andrew Morton
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=CBDB88BFD06F7F408399DBCF8776B3DC0322102A@scsmsx403.amr.corp.intel.com \
--to=hongjiu.lu@intel.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nanhai.zou@intel.com \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®