Re: 8.0.0beta1: make check fails on solaris8 - Mailing list pgsql-bugs

From Michael Fuhr
Subject Re: 8.0.0beta1: make check fails on solaris8
Date
Msg-id 20040811142503.GA75182@winnie.fuhr.org
Whole thread Raw
In response to Re: 8.0.0beta1: make check fails on solaris8  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
On Wed, Aug 11, 2004 at 09:36:30AM -0400, Tom Lane wrote:
> Martin Münstermann <mmuenstermann@betrusted.com> writes:
> > It's even a little more bizarre:
> > When I start a fresh psql session, SELECT 'infinity'::float4 just works.
> > Then I \i sql/float4.sql, and after that
> > template1=# \set VERBOSITY verbose
> > template1=# SELECT 'infinity'::float4;
> > ERROR:  22P02: invalid input syntax for type real: "infinity"
> > LOCATION:  float4in, float.c:330
>
> Wow.  Well, that confirms my suspicion that endptr is bad --- the line
> number shows that the complaint is coming from the
> junk-at-end-of-the-string test.  But why is it history-dependent?
>
> I wonder if endptr might not be getting set at all in this case.

I've replied on this topic a couple of times in the "SOLARIS 9
ULTRASPARC BUILD" thread, but perhaps my messages aren't getting
through.  On Solaris, when strtod() parses "infinity" or its
equivalent, it sets endptr one character beyond where it should.
This is apparently a longstanding bug that's allegedly been fixed
in Solaris 10:

http://groups.google.com/groups?threadm=4118e611%241_3%40omega.dimensional.com

Here's the example program from the above post to comp.unix.solaris:

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>

int
main(void)
{   double  val;   char   *endptr;   char    num[] = {'i', 'n', 'f', 'i', 'n', 'i', 't', 'y', '\0',
'x','y', 'z', '\0'}; 
   errno = 0;   val = strtod(num, &endptr);   printf("val = %f, errno = %d, endptr = %s\n", val, errno, endptr);
   return 0;
}

On Solaris 9 this program produces the following output:

val = Inf, errno = 0, endptr = xyz

As the output shows, endptr is set to one character beyond the end
of the "infinity" string.  Perhaps the history-dependence in
PostgreSQL is due to endptr being set to point to memory that's
zeroed during the first call to strtod(), but that gets filled with
data before subsequent calls.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/


pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: 8.0.0beta1: make check fails on solaris8
Next
From: Michael Fuhr
Date:
Subject: Re: 8.0.0beta1: make check fails on solaris8