Subject: Re: lib/19638: isalpha (3) bug
To: None <>
From: Mike Cheponis <mac@Wireless.Com>
List: netbsd-bugs
Date: 01/03/2003 16:31:05
> You don't like it, that's all.

If you will.  I think it's wrong.

> > > > 1)  Here are the OSs that this program works without a problem:
> > > > o Digital UNIX V4.0B  (Rev. 564); Tue Dec 14 15:43:30 EST 1999
> > > > o FreeBSD 4.2-RELEASE #2: Sun Mar  4 12:11:05 PST 2001
> > > > o BSDI BSD/OS 4.0 Kernel #6: Thu Jan 21 12:47:23 PST 1999
> FWIW, here are my results:
> The strings are the output of `uname -mrspv':
> SunOS 5.8 Generic_108528-15 sun4u sparc
> SunOS 5.9 Generic_112233-03 sun4u sparc
> OSF1 V4.0 1229 alpha alpha (This V4.0F)
> IRIX 6.2 03131015 IP22 mips

> In all cases your program gets killed by a SIGSEGV and isalpha() does
> return non-zero for many other values than [a-zA-Z].
> > I did the tests, and your assertion is incorrect.  Here is the test
> > prog:

I'm just trying to illustrate the problem, not build the World's Best Test
program.    You're welcome to share the program you used on the above systems,
complete with your Excellent Style example.  Thanks.

(Style is in the eyes of the beholder.  I don't want to go there, please. I
 have argued previously how much of the KNF is broken, and got people to
 agree, but it won't change anyway.  Sigh.)

> > > >     Feeding a routine in libc a perfectly valid int should NOT
> > > >     cause the libc routine to segfault.  That is Bad.

> This is totally bogus argument. Please, show me an *invalid* int.


> isalpha() - like most other routines in libc - is not fool-safe, you
> have to read the documentation before you use one routine and have to
> follow its rules.

Again: > > FreeBSD and BSDI don't have this bug; why does NetBSD ?

> Would you ever have noticed your misuse of isalpha() if your program had
> not crashed? So you prefer silently corrupting data over an obvious
> crash pointing you directly to your problem?

I was NOT misusing isalpha().  This is my point!  ;-)

Explain to me how silent data corruption occurs when isalpha() behaves
correctly (my defintion of correct)?  I just want to know if the damn int
is an alpha or not!  Is that TOO MUCH TO ASK ???

> You do not only want the implementation not to crash you also want it to
> decide whether a non-character is"alpha" or not. This is out of the
> scope of isalpha().

So, what you are saying is that if a value sent to isalpha() is not an
alpha, then isalpha() is not supposed to tell you without segfaulting?  My,
that seems VERY strange to me...

> It's not supposed to handle such values and relying
> on the behaviour a specific implementation might do for invalid input is
> simply a bad habbit, i.e. not portable.

Excuse me!

What I have been saying is that there are better-behaved implementations,
like those on FreeBSD and BSDI, and I believe that NetBSD's implemention
should be similarly behaved.

Clearly, the user communities of FreeBSD and BSDI think what I'm suggesting
makes sense.

Or, to put it another way, if you think that segfaulting is the proper
response, don't you think NetBSD should convince FreeBSD and BSDI of their
obviously inferior implmentation?

> Christian