Re: 8.0.0beta1: make check fails on solaris8

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Martin M?nstermann <mmuenstermann(at)betrusted(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: 8.0.0beta1: make check fails on solaris8
Date: 2004-08-11 14:25:03
Message-ID: 20040811142503.GA75182@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Aug 11, 2004 at 09:36:30AM -0400, Tom Lane wrote:
> =?ISO-8859-15?Q?Martin_M=FCnstermann?= <mmuenstermann(at)betrusted(dot)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/

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Fabien COELHO 2004-08-11 14:29:03 Re: broken contrib/dbsize in cvs head?
Previous Message Tom Lane 2004-08-11 14:12:43 Re: 8.0.0beta1: make check fails on solaris8