From nobody@FreeBSD.org  Wed Oct 19 12:20:05 2005
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id E234616A420
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 19 Oct 2005 12:20:05 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 608F343D49
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 19 Oct 2005 12:20:05 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j9JCK4ca005688
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 19 Oct 2005 12:20:04 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id j9JCK4wD005687;
	Wed, 19 Oct 2005 12:20:04 GMT
	(envelope-from nobody)
Message-Id: <200510191220.j9JCK4wD005687@www.freebsd.org>
Date: Wed, 19 Oct 2005 12:20:04 GMT
From: Niall Murphy <niallm@avernus.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: IO::AIO test suite loops infinitely on 5.4-RELEASE-p5
X-Send-Pr-Version: www-2.3

>Number:         87658
>Category:       kern
>Synopsis:       IO::AIO test suite loops infinitely on 5.4-RELEASE-p5
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 19 12:30:15 GMT 2005
>Closed-Date:    Sun Mar 02 02:34:46 UTC 2008
>Last-Modified:  Sun Mar 02 02:34:46 UTC 2008
>Originator:     Niall Murphy
>Release:        5.4-RELEASE-p5
>Organization:
Amazon.COM
>Environment:
FreeBSD leonidas.avernus.net 5.4-RELEASE-p5 FreeBSD 5.4-RELEASE-p5 #1: Fri Jul 22 15:02:14 UTC 2005     niallm@leonidas.avernus.net:/usr/obj/usr/src/sys/LEONIDAS  i386
>Description:
Something is wrong somewhere either in the AIO
implementation in FreeBSD, threading in FreeBSD,
or some expectation in how IO::AIO expects the above
to work. Running the test suite, and specifically
test number 2, stat, causes an infinite loop.
>How-To-Repeat:
Download IO::AIO 1.6x from CPAN. (It's probably
sufficient to do perl -eshell -MCPAN install IO::AIO.) Run the test suite with 'make test',
and then watch the suite hang at

t/01_stat.......

Pressing ctrl-T gives the following:

load: 1.51  cmd: perl5.8.6 75059 [runnable] 0.84u 0.07s 2% 2900k
load: 1.51  cmd: perl5.8.6 75059 [runnable] 2.00u 0.16s 6% 2900k
load: 1.58  cmd: perl5.8.6 75059 [runnable] 2.71u 3.34s 20% 2880k
load: 1.62  cmd: perl5.8.6 75059 [runnable] 3.20u 6.06s 28% 2880k

If you ctrl-C out, the test perl process continues running:

niallm@leonidas IO-AIO-1.61 $ ps auxww|grep -i perl
root    74237 53.6  0.6  3676  2916  p6  R    12:09PM  15:01.65 /usr/bin/perl -w t/01_stat.t (perl5.8.6)
niallm  75059 47.5  0.6  3672  2896  p6  R    12:25PM   0:11.92 /usr/bin/perl -w t/01_stat.t (perl5.8.6)

ktracing the processes gives:
leonidas# ktrace -p 74237
leonidas# kdump
 74237 perl5.8.6 PSIG  SIGSEGV SIG_DFL
 74237 perl5.8.6 PSIG  SIGSEGV SIG_DFL
 74237 perl5.8.6 PSIG  SIGSEGV SIG_DFL
 74237 perl5.8.6 PSIG  SIGSEGV SIG_DFL
 74237 perl5.8.6 PSIG  SIGSEGV SIG_DFL
 74237 perl5.8.6 PSIG  SIGSEGV SIG_DFL
 74237 perl5.8.6 PSIG  SIGSEGV SIG_DFL
 74237 perl5.8.6 PSIG  SIGSEGV SIG_DFL
[repeat until dead]

>Fix:
              
>Release-Note:
>Audit-Trail:

From: Peter Edwards <peter.edwards@vordel.com>
To: bug-followup@FreeBSD.org,  niallm@avernus.net
Cc:  
Subject: Re: kern/87658: IO::AIO test suite loops infinitely on 5.4-RELEASE-p5
Date: Wed, 23 Nov 2005 18:48:48 +0000

 There are two distinct problems here, one which causes a crash on 5.x, 
 the other causing problems for 6.x
 
 First off, perl on 5.x is not linked with -lpthread, as a result, the 
 threading library is in something of a muddle when it loads dynamic 
 modules that need thread support. You can hack your way out of this with
 
 env LD_PRELOAD=/usr/lib/libpthread.so perl <blah>
 
 The second problem is that the AIO implementation creates IO stacks with 
 tiny threads (8K), but has two local functions with 4K on-stack buffers 
 ("readahead", and "sendfile_") which GCC appears to helpfully inline 
 into "aio_proc", allocating more than 8K of stack space up front. This 
 is easy enough to fix:
 
 --------8<--------
 --- AIO.xs.orig Wed Nov 23 18:17:53 2005
 +++ AIO.xs      Mon Nov 21 20:51:47 2005
 @@ -36,7 +36,7 @@
  #if __ia64
  # define STACKSIZE 65536
  #else
 -# define STACKSIZE  8192
 +# define STACKSIZE  16384
  #endif
 
  enum {
 --------8<--------
 
 I'd have thought there was enough info available to the compiler to 
 re-use the same 4K of stack for both inlined functions, rather than 
 allocating separate space for each, but I'm not a compiler expert. At 
 best, it seems like a POLA violation, but it looks more like a bug to 
 me: The compiler on FreeBSD 5.x doesn't seem to do it...
 
State-Changed-From-To: open->analyzed 
State-Changed-By: peadar 
State-Changed-When: Wed Nov 23 19:00:10 GMT 2005 
State-Changed-Why:  
Problem described by previous post. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=87658 
State-Changed-From-To: analyzed->feedback 
State-Changed-By: kmacy 
State-Changed-When: Fri Nov 16 09:19:16 UTC 2007 
State-Changed-Why:  

Both AIO and threads have seen substantial re-work. Is this still an issue on RELENG_7? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=87658 
State-Changed-From-To: feedback->closed 
State-Changed-By: linimon 
State-Changed-When: Sun Mar 2 02:34:33 UTC 2008 
State-Changed-Why:  
Feedback timeout (> 3 months). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=87658 
>Unformatted:
