From owner-freebsd-arch@FreeBSD.ORG Mon Oct 1 09:21:22 2012 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 35D8A106564A; Mon, 1 Oct 2012 09:21:22 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id A9A468FC0C; Mon, 1 Oct 2012 09:21:21 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q919LPnu014171; Mon, 1 Oct 2012 12:21:25 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q919LDt4016033; Mon, 1 Oct 2012 12:21:13 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q919LDdb016032; Mon, 1 Oct 2012 12:21:13 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 1 Oct 2012 12:21:13 +0300 From: Konstantin Belousov To: John Baldwin Message-ID: <20121001092113.GH35915@deviant.kiev.zoral.com.ua> References: <201209281847.39663.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Zlo2GrDIozf6aQFY" Content-Disposition: inline In-Reply-To: <201209281847.39663.jhb@freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: arch@freebsd.org Subject: Re: stdio and short file descriptors revisited X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Oct 2012 09:21:22 -0000 --Zlo2GrDIozf6aQFY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Sep 28, 2012 at 06:47:39PM -0400, John Baldwin wrote: > Four years or so ago I cleaned up some of the stdio internals as fallout = =66rom=20 > running into problems with stdio using a short instead of an int to hold = file=20 > descriptors. Back then I got sidetracked with attempting to make FILE op= aque=20 > and ended up never getting around to bumping _file from a short to an int= =2E I=20 > recently ran back into the SHRT_MAX limit at work again and came up with = a=20 > patch to fix this. >=20 > To preserve the ABI, it is necessary to leave the existing short _file in= =20 > place and add a new int _file to the end of the FILE structure. Also, fo= r old=20 > applications, the old _file (_ofile in the patch) must still be valid. T= he=20 > approach I have taken is to bump the symbol version for routines that cre= ate=20 > FILE objects with a non-fake _file (fopen, fdopen, and freopen). The old= =20 > FBSD_1.0 variants still fail if an fd is greater than SHRT_MAX (and thus= =20 > cannot be safely stored in _ofile). The new FBSD_1.3 variants assign to = both=20 > _file and _ofile if the fd is less than SHRT_MAX. I also changed fileno() > to no longer be an inline macro in but to always be a function = call=20 > going forward. >=20 > If folks think this is ok, I'll hack up a modified version that hides _fi= le > 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 a= pps > accessing _file directly. >=20 > http://www.FreeBSD.org/~jhb/patches/stdio_file.patch The corner case left unhandled is the situation where we have a dso which is linked against FBSD_1.0 version of libc, but which gets FILE * as an API argument for some of its exported routines. If the implementation uses fileno(3), it would fail. I have no idea how to fix this, most likely, the issue is not fixable at all. Workaround seems to be to force the __isthreaded to 1. Might be, as an ugly hack, some flag could be added to the stdbuf(1), if anybody cares enough. Otherwise, the patch looks good. --Zlo2GrDIozf6aQFY Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAlBpYIkACgkQC3+MBN1Mb4gCHwCg1XHzpsvs6LeerJaEtZXC87/x 0dEAoPOL19RkL5gOVOc0lvvzKTsMFjY+ =6tu+ -----END PGP SIGNATURE----- --Zlo2GrDIozf6aQFY--