Bug 3894 - pty race condition in 2.6 kernel on SMP machine
Summary: pty race condition in 2.6 kernel on SMP machine
Status: CLOSED CODE_FIX
Alias: None
Product: Process Management
Classification: Unclassified
Component: Other (show other bugs)
Hardware: i386 Linux
: P2 normal
Assignee: process_other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-13 16:00 UTC by H.J. Lu
Modified: 2005-01-07 16:39 UTC (History)
1 user (show)

See Also:
Kernel Version: 2.6.10-rc3
Subsystem:
Regression: ---
Bisected commit-id:


Attachments
A testcase (709 bytes, text/plain)
2004-12-13 16:03 UTC, H.J. Lu
Details
A patch for 2.6.10-rc3 (525 bytes, patch)
2004-12-16 13:09 UTC, H.J. Lu
Details | Diff
The config file for P4 SMP machine (46.36 KB, text/plain)
2004-12-17 09:05 UTC, H.J. Lu
Details
A patch for kernel 2.4.29 (572 bytes, patch)
2004-12-17 12:36 UTC, H.J. Lu
Details | Diff

Description H.J. Lu 2004-12-13 16:00:02 UTC
There seems a pty race condition in 2.6 kernel on SMP machines. I have seen it on
dual ia32 and ia64 machines under 2.6.10-rc3.
Comment 1 H.J. Lu 2004-12-13 16:03:58 UTC
Created attachment 4260 [details]
A testcase

On my dual 2.8GHz P4 machine with 1GB RAM, I got

# nohup make&
# ps xa
 5159 pts/0    S      0:00 make
 5160 pts/0    S      0:01 /bin/sh -c for ((i = 0; i < 50000; i++)) do	echo
$i;
11540 pts/0    S      0:00 ./pty
11541 ?        Zs     0:00 [true] <defunct>
# tail nohup.out
3186
select (4) returns: 1
Read -1 characters.
3187
select (4) returns: 1
Read -1 characters.
3188
select (4) returns: 1
Read -1 characters.
3189
Comment 2 Andrew Morton 2004-12-13 21:11:45 UTC
Are you sure it's a bug?  I get the same behaviour on 2.4.29-pre1.
Comment 3 H.J. Lu 2004-12-14 09:15:48 UTC
I have seen it under 2.4.2x SMP kernel too. Since the current behavior isn't
consistent with itself nor UP kernel, I consider it a bug. What do other OSes do?
Comment 4 H.J. Lu 2004-12-16 13:09:45 UTC
Created attachment 4270 [details]
A patch for 2.6.10-rc3

I got this patch for 2.6.10-rc3 from Nanhai Zou, nanhai.zou@intel.com.
It works for me. A similar patch for 2.4 kernel also works.
Comment 5 Andrew Morton 2004-12-17 00:07:47 UTC
It doesn't work for me.  I still get

539
select (3) returns: 1
Read -1 characters.
errno: Input/output error
540
select (3) returns: 1
Read -1 characters.
errno: Input/output error
Comment 6 H.J. Lu 2004-12-17 09:05:04 UTC
Created attachment 4276 [details]
The config file for P4 SMP machine

Sorry I didn't make myself clear. The problem is my testcase may
hang on a fast SMP machine. I have seen it on a quad 1.3GHz Itanium 2,
a dual 800MHz Itanium 1, a single P4 HT and a single EM64T HT. It
happens on both 2.4 and 2.6 SMP kernels.
Comment 7 Andrew Morton 2004-12-17 11:49:28 UTC
yup, I was able to reproduce the hang on an unpatched kernel too.

I'll merge the patch for 2.6.10, thanks.  Maybe 2.4 needs a patch
too??
Comment 8 H.J. Lu 2004-12-17 12:36:29 UTC
Created attachment 4277 [details]
A patch for kernel 2.4.29

This patch should apply to kernel 2.4.29.
Comment 9 Alexander Nyberg 2005-01-07 16:39:54 UTC
Fix is in mainline, closing.

Note You need to log in before you can comment on or make changes to this bug.