delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2012/01/23/20:02:47

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-0.4 required=5.0 tests=AWL,BAYES_00,SPF_NEUTRAL
X-Spam-Check-By: sourceware.org
Message-ID: <4F1E031C.4020604@cs.utoronto.ca>
Date: Mon, 23 Jan 2012 20:02:20 -0500
From: Ryan Johnson <ryan DOT johnson AT cs DOT utoronto DOT ca>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0) Gecko/20111222 Thunderbird/9.0.1
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: isprint core dump
References: <4F1DC95A DOT 6020409 AT redhat DOT com> <2BF01EB27B56CC478AD6E5A0A28931F203DD4166 AT A1DAL1SWPES19MB DOT ams DOT acs-inc DOT net> <4F1DD3A6 DOT 7060205 AT redhat DOT com>
In-Reply-To: <4F1DD3A6.7060205@redhat.com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On 23/01/2012 4:39 PM, Eric Blake wrote:
> On 01/23/2012 02:34 PM, Nellis, Kenneth wrote:
>> From: Eric Blake
>>
>>> No, but it DOES come from POSIX:
>>> http://pubs.opengroup.org/onlinepubs/9699919799/functions/isprint.html
>>>
>>> And cygwin's behavior matches POSIX on this point; the bug is in your
>>> program, not cygwin.
>> Call me blown away by the level of support this function that
>> dumps core is getting, when it could act sanely (IMHO) with a
>> simple "if" statement! So much for defensive programming.
> If you want defensive programming, write the defense into your program -
> don't call functions with invalid arguments in the first place.  It
> costs time to process an if() statement that would be reached by every
> single caller, when 99.99% of the callers already comply with the
> standards.
That, and the if() would almost certainly mask the bug -- there's no 
value isprint() can return to signal an error, and if the sad state of 
errno and error code checking in general is any indication, the error 
condition would be ignored by 99.99% of buggy callers even if isprint() 
did signal it in some way.

I, for one, prefer my invalid code to trigger a nice, predictable seg 
fault immediately, rather than returning undefined results and/or 
causing malloc() to barf at some indeterminate point in the future.

Ryan


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019