Following test end up with the server crash into 8.4 cvs Head.

uname -a
Linux localhost.localdomain 2.6.18-53.el5 #1 SMP Wed Oct 10 16:34:19 EDT
2007 x86_64 x86_64 x86_64 GNU/Linux

Testcase with ISN contrib module:
=========================

CREATE OR REPLACE function isbn_issn_proc() returns void as
$$
declare
v1 isbn;
BEGIN
        v1 := isbn_in('0-596-00270-x');
END;
$$ LANGUAGE plpgsql;

select isbn_issn_proc();

Analysis:
=======

Found that we are getting crash while doing the memcpy into datumCopy().

Datum
datumCopy(Datum value, bool typByVal, int typLen)
{
...
       if (DatumGetPointer(value) == NULL)
           return PointerGetDatum(NULL);

       realSize = datumGetSize(value, typByVal, typLen);

       s = (char *) palloc(realSize);
       memcpy(s, DatumGetPointer(value), realSize);  /* crash */
}

Actually we get crash while doing the DatumGetPointer(), upon further
investigation found that  in isbn_in() function we are using
PG_RETURN_EAN13(), which seems to be returning the wrong address in case of
64bit OS.

I was wondering that why its happening in PG 8.4; then found that we are
having USE_FLOAT8_BYVAL into current version, because of the same not
getting correct/expected Datum representation of the int64.

postgres.h

#ifdef USE_FLOAT8_BYVAL
#define Int64GetDatum(X) ((Datum) SET_8_BYTES(X))
#else
extern Datum Int64GetDatum(int64 X);
#endif

When I tried the same case with --disable-float8-byval option, test running
as expected.



Regards,
Rushabh Lathia

www.EnterpriseDB.com

Reply via email to