From owner-freebsd-standards@FreeBSD.ORG Sun Mar 18 22:35:07 2012 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4F7E9106564A for ; Sun, 18 Mar 2012 22:35:07 +0000 (UTC) (envelope-from freebsd-standards@m.gmane.org) Received: from plane.gmane.org (plane.gmane.org [80.91.229.3]) by mx1.freebsd.org (Postfix) with ESMTP id 052E38FC14 for ; Sun, 18 Mar 2012 22:35:06 +0000 (UTC) Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1S9Ogp-0005gP-WF for freebsd-standards@freebsd.org; Sun, 18 Mar 2012 23:35:04 +0100 Received: from 201.82.200.35 ([201.82.200.35]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 18 Mar 2012 23:35:03 +0100 Received: from rakuco by 201.82.200.35 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 18 Mar 2012 23:35:03 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: freebsd-standards@freebsd.org From: Raphael Kubo da Costa Date: Sun, 18 Mar 2012 19:24:44 -0300 Lines: 18 Message-ID: <87haxlh7ir.fsf@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 201.82.200.35 User-Agent: Gnus/5.130004 (Ma Gnus v0.4) Emacs/24.0.93 (berkeley-unix) Cancel-Lock: sha1:4FnQSORDdR471ZkTFLdswj6MD5Y= Cc: freebsd-threads@freebsd.org Subject: Should __clockid_t be used instead of clockid_t in pthread.h? X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Mar 2012 22:35:07 -0000 Hi there. I'm trying to build an unstable glib version here, and one of their tests fails to build due to them #defining _POSIX_C_SOURCE to 0 and then #including , which produces the following error on my 8-STABLE machine: /usr/include/pthread.h:184: error: expected declaration specifiers or '...' before 'clockid_t' /usr/include/pthread.h:187: error: expected declaration specifiers or '...' before 'clockid_t' /usr/include/pthread.h:203: error: expected declaration specifiers or '...' before 'clockid_t' pthread.h gets its definition of clockid_t from time.h, but time.h only creates the typedef if __POSIX_VISIBLE is >= 199309. Using __clockid_t instead of clockid_t in the function prototypes works fine. Should the prototypes be changed? Thanks. From owner-freebsd-standards@FreeBSD.ORG Mon Mar 19 09:02:29 2012 Return-Path: Delivered-To: freebsd-standards@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0615B1065674; Mon, 19 Mar 2012 09:02:29 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail04.syd.optusnet.com.au (mail04.syd.optusnet.com.au [211.29.132.185]) by mx1.freebsd.org (Postfix) with ESMTP id 6DD588FC0A; Mon, 19 Mar 2012 09:02:27 +0000 (UTC) Received: from c211-30-171-136.carlnfd1.nsw.optusnet.com.au (c211-30-171-136.carlnfd1.nsw.optusnet.com.au [211.30.171.136]) by mail04.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id q2J92B0P004569 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 19 Mar 2012 20:02:20 +1100 Date: Mon, 19 Mar 2012 20:02:11 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Raphael Kubo da Costa In-Reply-To: <87haxlh7ir.fsf@FreeBSD.org> Message-ID: <20120319194821.H1024@besplex.bde.org> References: <87haxlh7ir.fsf@FreeBSD.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-standards@FreeBSD.org, freebsd-threads@FreeBSD.org Subject: Re: Should __clockid_t be used instead of clockid_t in pthread.h? X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Mar 2012 09:02:29 -0000 On Sun, 18 Mar 2012, Raphael Kubo da Costa wrote: > Hi there. > > I'm trying to build an unstable glib version here, and one of their > tests fails to build due to them #defining _POSIX_C_SOURCE to 0 and > then #including , which produces the following error on my > 8-STABLE machine: This gives undefined behaviour. > /usr/include/pthread.h:184: error: expected declaration specifiers or '...' before 'clockid_t' > /usr/include/pthread.h:187: error: expected declaration specifiers or '...' before 'clockid_t' > /usr/include/pthread.h:203: error: expected declaration specifiers or '...' before 'clockid_t' > > pthread.h gets its definition of clockid_t from time.h, but time.h only > creates the typedef if __POSIX_VISIBLE is >= 199309. Using __clockid_t > instead of clockid_t in the function prototypes works fine. > > Should the prototypes be changed? time.h is a standard C header, so not defining clockid_t in it when POSIX extensions are disabled is correct. pthread.h is a not-so-old POSIX header, so it can assume that __POSIX_VISIBLE is >= 199309. Including it when POSIX is not visible, or when only an older version of POSIX is visible, is just nonsense and can have any result, like the one here. While using __clockid_t in in might make it sort of work, it would remain quite broken. POSIX requires that pthread.h shall make all the namespace pollution in time.h (and some other headers) visible. This is a bug in POSIX. It actually requires that pthread.h shall make all the [POSIX] symbols in time.h visible. pthread.h just includes time.h to get all of these symbols, and becomes broken if ones like clockid_t are not declared. If pthread.h is actually used, then programs using it will actually need some of the symbols like clockid_t from time.h and break when they don't explicitly include time.h. Bruce From owner-freebsd-standards@FreeBSD.ORG Mon Mar 19 11:07:22 2012 Return-Path: Delivered-To: freebsd-standards@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B9E121065670 for ; Mon, 19 Mar 2012 11:07:22 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 8AE628FC16 for ; Mon, 19 Mar 2012 11:07:22 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q2JB7MEp033717 for ; Mon, 19 Mar 2012 11:07:22 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q2JB7LEg033715 for freebsd-standards@FreeBSD.org; Mon, 19 Mar 2012 11:07:21 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 19 Mar 2012 11:07:21 GMT Message-Id: <201203191107.q2JB7LEg033715@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: gnats set sender to owner-bugmaster@FreeBSD.org using -f From: FreeBSD bugmaster To: freebsd-standards@FreeBSD.org Cc: Subject: Current problem reports assigned to freebsd-standards@FreeBSD.org X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Mar 2012 11:07:22 -0000 Note: to view an individual PR, use: http://www.freebsd.org/cgi/query-pr.cgi?pr=(number). The following is a listing of current problems submitted by FreeBSD users. These represent problem reports covering all versions including experimental development code and obsolete releases. S Tracker Resp. Description -------------------------------------------------------------------------------- o stand/165236 standards The NONE Wi-Fi regulatory restricts use of channels 12 o stand/164787 standards dirfd() function not available when _POSIX_C_SOURCE is o kern/164674 standards [patch] [libc] vfprintf/vfwprintf return error (EOF) o o stand/162434 standards getaddrinfo: addrinfo.ai_family is an address family, o stand/154842 standards invalid request authenticator in the second and subseq o stand/150093 standards C++ std::locale support is broken s stand/141705 standards [libc] [request] libc lacks cexp (and friends) o stand/130067 standards Wrong numeric limits in system headers? o stand/124860 standards flockfile(3) doesn't work when the memory has been exh o stand/121921 standards [patch] Add leap second support to at(1), atrun(8) o stand/116477 standards rm(1): rm behaves unexpectedly when using -r and relat o bin/116413 standards incorrect getconf(1) handling of unsigned constants gi o stand/116081 standards make does not work with the directive sinclude p stand/107561 standards [libc] [patch] [request] Missing SUS function tcgetsid o stand/100017 standards [Patch] Add fuser(1) functionality to fstat(1) a stand/86484 standards [patch] mkfifo(1) uses wrong permissions o stand/82654 standards C99 long double math functions are missing o stand/81287 standards [patch] fingerd(8) might send a line not ending in CRL a stand/80293 standards sysconf() does not support well-defined unistd values o stand/79056 standards [feature request] [atch] regex(3) regression tests o stand/70813 standards [patch] ls(1) not Posix compliant o stand/66357 standards make POSIX conformance problem ('sh -e' & '+' command- s kern/64875 standards [libc] [patch] [request] add a system call: fdatasync( o stand/56476 standards [patch] cd9660 unicode support simple hack o stand/54410 standards one-true-awk not POSIX compliant (no extended REs) o stand/46119 standards Priority problems for SCHED_OTHER using pthreads o stand/44365 standards [headers] [patch] [request] introduce ulong and unchar a stand/41576 standards ln(1): replacing old dir-symlinks o stand/39256 standards snprintf/vsnprintf aren't POSIX-conformant for strings a docs/26003 standards getgroups(2) lists NGROUPS_MAX but not syslimits.h s stand/24590 standards timezone function not compatible witn Single Unix Spec o stand/21519 standards sys/dir.h should be deprecated some more s bin/14925 standards getsubopt isn't poisonous enough 33 problems total. From owner-freebsd-standards@FreeBSD.ORG Mon Mar 19 17:33:55 2012 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7B925106564A; Mon, 19 Mar 2012 17:33:55 +0000 (UTC) (envelope-from kubito@gmail.com) Received: from mail-yx0-f182.google.com (mail-yx0-f182.google.com [209.85.213.182]) by mx1.freebsd.org (Postfix) with ESMTP id 1E94E8FC18; Mon, 19 Mar 2012 17:33:54 +0000 (UTC) Received: by yenl9 with SMTP id l9so6845349yen.13 for ; Mon, 19 Mar 2012 10:33:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=4UsupB9tDCSpvMNaibXUq7JZG4Wx2MShhny1ffNm0KE=; b=Qizbu6HKWzABz3Xu/r/wbKMyic7WLw4ifPAsa0OcEWKVRTLwwhIgPEsnqVjZnibeB2 yHA0QEIQQX9Ii3BP0mXmaaQ+kCtQWleOJDe9Z40z8sXzVCxPrRfcSK3aMTWJGJ/p1Q7r DcjhPHH8K1Lq22cSFH+nxGammNdBVCV25yxIK68BtwRc0M661I3NHmuQ9pWbwUm6SrAx 7i3NODuY1UqGit8hWecjsyAHt1/GunzUIlVYJT6a+rayI9QAdrUP6Tiw9xdXULrhLBQS hr3gAW+vpkXHIRkuRupsNXys8QG4msZxBKZjeZT9fr1OyYOym8stodKEzUZI4TYx06JZ 99jQ== Received: by 10.60.18.137 with SMTP id w9mr14666398oed.7.1332178434262; Mon, 19 Mar 2012 10:33:54 -0700 (PDT) Received: from rachacuca.gmail.com (li113-135.members.linode.com. [69.164.198.135]) by mx.google.com with ESMTPS id 8sm13663132obv.19.2012.03.19.10.33.52 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 19 Mar 2012 10:33:53 -0700 (PDT) Sender: Raphael Kubo da Costa From: Raphael Kubo da Costa To: Bruce Evans References: <87haxlh7ir.fsf@FreeBSD.org> <20120319194821.H1024@besplex.bde.org> Date: Mon, 19 Mar 2012 14:34:51 -0300 In-Reply-To: <20120319194821.H1024@besplex.bde.org> (Bruce Evans's message of "Mon, 19 Mar 2012 20:02:11 +1100 (EST)") Message-ID: <83haxk8pfo.fsf@FreeBSD.org> User-Agent: Gnus/5.130004 (Ma Gnus v0.4) Emacs/23.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Cc: freebsd-standards@FreeBSD.org, freebsd-threads@FreeBSD.org Subject: Re: Should __clockid_t be used instead of clockid_t in pthread.h? X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Mar 2012 17:33:55 -0000 Bruce Evans writes: > On Sun, 18 Mar 2012, Raphael Kubo da Costa wrote: > >> Hi there. >> >> I'm trying to build an unstable glib version here, and one of their >> tests fails to build due to them #defining _POSIX_C_SOURCE to 0 and >> then #including , which produces the following error on my >> 8-STABLE machine: > > This gives undefined behaviour. > >> /usr/include/pthread.h:184: error: expected declaration specifiers or '...' before 'clockid_t' >> /usr/include/pthread.h:187: error: expected declaration specifiers or '...' before 'clockid_t' >> /usr/include/pthread.h:203: error: expected declaration specifiers or '...' before 'clockid_t' >> >> pthread.h gets its definition of clockid_t from time.h, but time.h only >> creates the typedef if __POSIX_VISIBLE is >= 199309. Using __clockid_t >> instead of clockid_t in the function prototypes works fine. >> >> Should the prototypes be changed? > > time.h is a standard C header, so not defining clockid_t in it when POSIX > extensions are disabled is correct. > > pthread.h is a not-so-old POSIX header, so it can assume that > __POSIX_VISIBLE is >= 199309. Including it when POSIX is not visible, > or when only an older version of POSIX is visible, is just nonsense > and can have any result, like the one here. While using __clockid_t > in in might make it sort of work, it would remain quite broken. POSIX > requires that pthread.h shall make all the namespace pollution in > time.h (and some other headers) visible. This is a bug in POSIX. It > actually requires that pthread.h shall make all the [POSIX] symbols > in time.h visible. pthread.h just includes time.h to get all of these > symbols, and becomes broken if ones like clockid_t are not declared. > If pthread.h is actually used, then programs using it will actually > need some of the symbols like clockid_t from time.h and break when > they don't explicitly include time.h. Thank you for the detailed explanation. I've filed a bug in glib's Bugzilla [1] with a proposed fix that should work on both FreeBSD and Linux. [1] https://bugzilla.gnome.org/show_bug.cgi?id=672406 From owner-freebsd-standards@FreeBSD.ORG Mon Mar 19 18:09:46 2012 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2C535106566C; Mon, 19 Mar 2012 18:09:46 +0000 (UTC) (envelope-from wollman@khavrinen.csail.mit.edu) Received: from khavrinen.csail.mit.edu (khavrinen.csail.mit.edu [128.30.28.20]) by mx1.freebsd.org (Postfix) with ESMTP id 89E2D8FC0C; Mon, 19 Mar 2012 18:09:45 +0000 (UTC) Received: from khavrinen.csail.mit.edu (localhost [127.0.0.1]) by khavrinen.csail.mit.edu (8.14.4/8.14.4) with ESMTP id q2JI9c6s056656 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL CN=khavrinen.csail.mit.edu issuer=Client+20CA); Mon, 19 Mar 2012 14:09:39 -0400 (EDT) (envelope-from wollman@khavrinen.csail.mit.edu) Received: (from wollman@localhost) by khavrinen.csail.mit.edu (8.14.4/8.14.4/Submit) id q2JI9csD056653; Mon, 19 Mar 2012 14:09:38 -0400 (EDT) (envelope-from wollman) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <20327.30306.939303.433270@khavrinen.csail.mit.edu> Date: Mon, 19 Mar 2012 14:09:38 -0400 From: Garrett Wollman To: Raphael Kubo da Costa In-Reply-To: <83haxk8pfo.fsf@FreeBSD.org> References: <87haxlh7ir.fsf@FreeBSD.org> <20120319194821.H1024@besplex.bde.org> <83haxk8pfo.fsf@FreeBSD.org> X-Mailer: VM 7.17 under 21.4 (patch 22) "Instant Classic" XEmacs Lucid X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.7 (khavrinen.csail.mit.edu [127.0.0.1]); Mon, 19 Mar 2012 14:09:39 -0400 (EDT) Cc: freebsd-standards@freebsd.org, freebsd-threads@freebsd.org Subject: Re: Should __clockid_t be used instead of clockid_t in pthread.h? X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Mar 2012 18:09:46 -0000 < said: > Thank you for the detailed explanation. I've filed a bug in glib's > Bugzilla [1] with a proposed fix that should work on both FreeBSD and > Linux. Unfortunately, your proposed fix has the result of requesting a *strict* POSIX environment, so applications that depend on system interfaces that were not in the 1993 threading amendments will no longer compile. Maybe this doesn't matter in the specific case of your testing framework, but it's not a universally correct solution. -GAWollman From owner-freebsd-standards@FreeBSD.ORG Wed Mar 21 21:45:33 2012 Return-Path: Delivered-To: standards@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4931F106566B; Wed, 21 Mar 2012 21:45:33 +0000 (UTC) (envelope-from das@FreeBSD.ORG) Received: from zim.MIT.EDU (ZIM.MIT.EDU [18.95.3.101]) by mx1.freebsd.org (Postfix) with ESMTP id 087618FC14; Wed, 21 Mar 2012 21:45:32 +0000 (UTC) Received: from zim.MIT.EDU (localhost [127.0.0.1]) by zim.MIT.EDU (8.14.5/8.14.2) with ESMTP id q2LLjP1p047027; Wed, 21 Mar 2012 17:45:25 -0400 (EDT) (envelope-from das@FreeBSD.ORG) Received: (from das@localhost) by zim.MIT.EDU (8.14.5/8.14.2/Submit) id q2LLjPgB047026; Wed, 21 Mar 2012 17:45:25 -0400 (EDT) (envelope-from das@FreeBSD.ORG) Date: Wed, 21 Mar 2012 17:45:25 -0400 From: David Schultz To: Matthew Story Message-ID: <20120321214525.GA46850@zim.MIT.EDU> Mail-Followup-To: Matthew Story , standards@freebsd.org, jhb@freebsd.org References: <201203041403.29020.jhb@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Cc: standards@FreeBSD.ORG, jhb@FreeBSD.ORG Subject: Re: PR kern/164674 X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Mar 2012 21:45:33 -0000 On Mon, Mar 12, 2012, Matthew Story wrote: > On Sun, Mar 4, 2012 at 2:03 PM, John Baldwin wrote: > > > My standard-parsing fu is weak. Can some other folks on this list look at > > this PR, figure out what the correct semantics for *fprintf() in this case, > > and evaluate the patch? Thanks. [...] > libc vfprintf currently behaves differently on un|buffered FILEs with > ferror set: > > 1. Unbuffered FILEs > > -> does not transmit any bytes, and returns -1 > > 2. Buffered FILEs (fully buffered, or line buffered) > > -> transmits all bytes, and returns -1 > > I believe that this should be reconciled such that vfprintf (and all > derivatives) returns sucess|failure based on transmission, not taking > ferror state into account, but an alternate solution would be to reconcile > the behavior of buffered FILEs with the current behavior of unbuffered > FILEs (e.g. detect ferror state, transmit no bytes and return -1). I agree with this assessment. When the error indicator is set on a stream, it means that an error has occurred at some point---not that all subsequent operations on the stream should fail. There ought to be a less ugly fix than the one proposed. Probably the PRINT macro and the various other evil macros in vfprintf() should set ret to EOF, and the following lines in vfprintf.c should be removed: if (__sferror(fp)) ret = EOF; If vfprintf() is fixed so that printing to a buffered stream always returns success after a successful write (regardless of the prior state of the stream's error indicator), that should fix the problem for unbuffered streams automatically. Unbuffered streams go through __sbprintf(), which throws away the output if vfprintf() returns -1. From owner-freebsd-standards@FreeBSD.ORG Thu Mar 22 03:43:25 2012 Return-Path: Delivered-To: standards@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 303651065670; Thu, 22 Mar 2012 03:43:25 +0000 (UTC) (envelope-from matthewstory@gmail.com) Received: from mail-vx0-f182.google.com (mail-vx0-f182.google.com [209.85.220.182]) by mx1.freebsd.org (Postfix) with ESMTP id BF2768FC12; Thu, 22 Mar 2012 03:43:24 +0000 (UTC) Received: by vcmm1 with SMTP id m1so2346220vcm.13 for ; Wed, 21 Mar 2012 20:43:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=mD7l6UNvTE4MLn2owDs1j92qphYDC8Aug8hD1nBuFCE=; b=NW7Iu1mqjF2Eaqzc2uLE3dNH06DTDib0ZIoB9oQTtbADhVgSI4wclVZEfMVEf9lL4X BKA/Y7u5KR9hiUEOQ+dc9aNjaUWZRYe1PXobd8surAAC/q8eDHJci+IbxpfJBkNfXnTr +B9aNhRHGpbDxuGez61UKeYRg7LKRApl24j6+fQwRyPYP6ySnwc9XrPffFZeVkDqfwR7 E7gv8Bj7seHhN/mH2dLHz/HRTGnF9P+fUTh+gMNGO1mB7R8vSwIEU+e6witSNcWIpl1k LYVjXP4mr6RZ0VS4M3XhbQ8ibNIajINj7TyheJS+1XnMlbMQHAMpJGepL9UJ0Okpg5Pz ySbg== MIME-Version: 1.0 Received: by 10.220.106.133 with SMTP id x5mr3068298vco.39.1332387804054; Wed, 21 Mar 2012 20:43:24 -0700 (PDT) Received: by 10.52.185.65 with HTTP; Wed, 21 Mar 2012 20:43:24 -0700 (PDT) In-Reply-To: <20120321214525.GA46850@zim.MIT.EDU> References: <201203041403.29020.jhb@freebsd.org> <20120321214525.GA46850@zim.MIT.EDU> Date: Wed, 21 Mar 2012 23:43:24 -0400 Message-ID: From: Matthew Story To: Matthew Story , standards@freebsd.org, jhb@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Subject: Re: PR kern/164674 X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Mar 2012 03:43:25 -0000 On Wed, Mar 21, 2012 at 5:45 PM, David Schultz wrote: > On Mon, Mar 12, 2012, Matthew Story wrote: > > On Sun, Mar 4, 2012 at 2:03 PM, John Baldwin wrote: > [...snip] > There ought to be a less ugly fix than the one proposed. Probably > the PRINT macro and the various other evil macros in vfprintf() > should set ret to EOF, and the following lines in vfprintf.c should > be removed: > > if (__sferror(fp)) > ret = EOF; > > If vfprintf() is fixed so that printing to a buffered stream > always returns success after a successful write (regardless of the > prior state of the stream's error indicator), that should fix the > problem for unbuffered streams automatically. Unbuffered streams > go through __sbprintf(), which throws away the output if > vfprintf() returns -1. > yeah ... I wasn't overly pleased with my fix as it stands. my concern was that the __sferror(fp) acts as a catch-all for any non-handled error case in the actual print logic. there are only 2 places in the function that explicitly set __SERR and goto error. i'll do a thorough audit of all potential side-effects of the above calls re: __SERR, and follow-up with something less butchered. -- regards, matt From owner-freebsd-standards@FreeBSD.ORG Fri Mar 23 19:10:14 2012 Return-Path: Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 16AD4106566B for ; Fri, 23 Mar 2012 19:10:14 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id E36B78FC19 for ; Fri, 23 Mar 2012 19:10:13 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q2NJAD9N029559 for ; Fri, 23 Mar 2012 19:10:13 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q2NJADKM029558; Fri, 23 Mar 2012 19:10:13 GMT (envelope-from gnats) Resent-Date: Fri, 23 Mar 2012 19:10:13 GMT Resent-Message-Id: <201203231910.q2NJADKM029558@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-standards@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Nathan Weeks Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 414CF106564A for ; Fri, 23 Mar 2012 19:06:40 +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 2C65F8FC15 for ; Fri, 23 Mar 2012 19:06:40 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q2NJ6dJL040372 for ; Fri, 23 Mar 2012 19:06:39 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id q2NJ6cs5040371; Fri, 23 Mar 2012 19:06:38 GMT (envelope-from nobody) Message-Id: <201203231906.q2NJ6cs5040371@red.freebsd.org> Date: Fri, 23 Mar 2012 19:06:38 GMT From: Nathan Weeks To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: standards/166349: Support the assignment-allocation character for fscanf()/scanf()/sscanf() X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Mar 2012 19:10:14 -0000 >Number: 166349 >Category: standards >Synopsis: Support the assignment-allocation character for fscanf()/scanf()/sscanf() >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Mar 23 19:10:13 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Nathan Weeks >Release: 9.0 >Organization: USDA-ARS >Environment: FreeBSD 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan 3 07:46:30 UTC 2012 root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64 >Description: In POSIX.1-2008, the %c , %s , and %[ conversion specifiers in a fscanf()/scanf()/sscanf() format string accept an optional assignment-allocation character 'm' to allocate a memory buffer large enough to hold the converted string: http://pubs.opengroup.org/onlinepubs/9699919799/functions/fscanf.html This functionality is useful for safely reading formatted input strings of unknown size. The FreeBSD 9.0 libc does not support this feature. In addition, the gcc 4.6.3 port silently accepts the assignment-allocation character, even when "-Wall" is specified, but a memory buffer is apparently not allocated at run time. >How-To-Repeat: Compile the attached program (scanf_m.c) using the base gcc 4.2.1: ##################################### $ gcc -Wall scanf_m.c scanf_m.c: In function 'main': scanf_m.c:6: warning: unknown conversion type character 'm' in format scanf_m.c:6: warning: too many arguments for format $ echo test | ./a.out H?? Segmentation fault (core dumped) ##################################### Using the gcc 4.6.3 port: ##################################### $ gcc46 -Wall scanf_m.c $ echo test | ./a.out H?? Segmentation fault (core dumped) ##################################### >Fix: Patch attached with submission follows: #include #include int main(void) { char *strptr; if (scanf("%m[^\n]\n", &strptr) == EOF) { perror("scanf"); return 1; } printf("%s\n", strptr); free(strptr); return 0; } >Release-Note: >Audit-Trail: >Unformatted: