This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: isprint core dump


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]