From nobody@FreeBSD.org  Thu Oct  4 18:49:10 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id D5EDF106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  4 Oct 2012 18:49:10 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id A5C4E8FC14
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  4 Oct 2012 18:49:10 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id q94InAhQ025429
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 4 Oct 2012 18:49:10 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id q94InA3H025428;
	Thu, 4 Oct 2012 18:49:10 GMT
	(envelope-from nobody)
Message-Id: <201210041849.q94InA3H025428@red.freebsd.org>
Date: Thu, 4 Oct 2012 18:49:10 GMT
From: John Baldwin <jhb@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [exp-run] Expanding stdio's internal file descriptors from short to int
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         172332
>Category:       ports
>Synopsis:       [exp-run] Expanding stdio's internal file descriptors from short to int
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    portmgr
>State:          suspended
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Oct 04 18:50:10 UTC 2012
>Closed-Date:    
>Last-Modified:  Wed Feb 20 05:23:31 UTC 2013
>Originator:     John Baldwin
>Release:        HEAD
>Organization:
>Environment:
>Description:
On Friday, September 28, 2012 6:47:39 pm John Baldwin wrote:
> Four years or so ago I cleaned up some of the stdio internals as fallout from 
> running into problems with stdio using a short instead of an int to hold file 
> descriptors.  Back then I got sidetracked with attempting to make FILE opaque 
> and ended up never getting around to bumping _file from a short to an int.  I 
> recently ran back into the SHRT_MAX limit at work again and came up with a 
> patch to fix this.
> 
> To preserve the ABI, it is necessary to leave the existing short _file in 
> place and add a new int _file to the end of the FILE structure.  Also, for old 
> applications, the old _file (_ofile in the patch) must still be valid.  The 
> approach I have taken is to bump the symbol version for routines that create 
> FILE objects with a non-fake _file (fopen, fdopen, and freopen).  The old 
> FBSD_1.0 variants still fail if an fd is greater than SHRT_MAX (and thus 
> cannot be safely stored in _ofile).  The new FBSD_1.3 variants assign to both 
> _file and _ofile if the fd is less than SHRT_MAX.  I also changed fileno()
> to no longer be an inline macro in <stdio.h> but to always be a function call 
> going forward.
> 
> If folks think this is ok, I'll hack up a modified version that hides _file
> from outside consumers (rename it to _nfile or some such) and send it for a
> ports-exp run before committing to make sure there aren't any 3rd party apps
> accessing _file directly.

I have a slightly modified version of my original patch that should hide _file
completely from any package builds.  No ports should be directly accessing the
internals of FILE.  They should be using things like fileno() instead.  Can
you do an exp-run with a patched world to see if there are any such abusers?
The patch is MI, so I think just doing one architecture should be sufficient.

http://www.FreeBSD.org/~jhb/patches/stdio_file_exp.patch

>How-To-Repeat:

>Fix:


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->analyzed 
State-Changed-By: linimon 
State-Changed-When: Wed Oct 10 00:00:11 UTC 2012 
State-Changed-Why:  
take. 


Responsible-Changed-From-To: freebsd-ports-bugs->linimon 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Wed Oct 10 00:00:11 UTC 2012 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=172332 
State-Changed-From-To: analyzed->feedback 
State-Changed-By: linimon 
State-Changed-When: Wed Oct 10 05:05:08 UTC 2012 
State-Changed-Why:  
The first major failure is in, and it affects almost half the Ports 
Collection: 

http://pointyhat-west.isc.FreeBSD.org/errorlogs/amd64-errorlogs/a.10-exp.20121010024913.pointyhat-west/perl-5.14.2_2.log 

http://www.freebsd.org/cgi/query-pr.cgi?pr=172332 
State-Changed-From-To: feedback->suspended 
State-Changed-By: linimon 
State-Changed-When: Wed Oct 10 18:32:15 UTC 2012 
State-Changed-Why:  
Mark suspended awaiting updated patch. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=172332 
State-Changed-From-To: suspended->suspended 
State-Changed-By: linimon 
State-Changed-When: Wed Feb 20 05:19:37 UTC 2013 
State-Changed-Why:  
I am no longer in a position to test this. 


Responsible-Changed-From-To: linimon->portmgr 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Wed Feb 20 05:19:37 UTC 2013 
Responsible-Changed-Why:  

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