glibc segfault on "special" long double values is _ok_!?

John Haxby jch@scalix.com
Wed Jun 6 14:08:00 GMT 2007


Andreas Schwab wrote:
>> I'm surprised to hear you arguing that it is desirable for glibc's printf
>> implementation to segfault for a long-double with an unusual bit pattern.
>>     
>
> In which way is this different from printf("%s", (char*)1)?
>   
In that it doesn't dereference a pointer?  You can say that, yes, it's a 
valid pointer and you can do things like pointer arithmetic with it in 
the same way that the odd long-double values are valid in that you can 
do long-double operations with them and by that token there's no need 
for printf() to behave itself.  On the other hand, you can pass those 
odd long-double values to, say, sqrt() and they'll not crash either (I'm 
guessing) whereas something that doesn't point to a null-terminated 
sequence of bytes will likely make strlen() crash.

I may be naïve here, but I don't think it's meaningful to compare the 
behaviour of bad pointers to the behaviour of strangelong-double 
numbers.  I'm saying you're wrong, but I don't think that there's a 
strong case for drawing that parallel -- in particular it seems rather 
odd to me that one would have to test any sort of number to make sure 
that it's printable.

jch



More information about the Libc-alpha mailing list