Server Crash into contrib module ISN into 64bit OS

Started by Rushabh Lathiaabout 17 years ago3 messages
#1Rushabh Lathia
rushabh.lathia@gmail.com

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

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Rushabh Lathia (#1)
Re: Server Crash into contrib module ISN into 64bit OS

"Rushabh Lathia" <rushabh.lathia@gmail.com> writes:

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

Hmm, this'd have been noticed sooner if contrib/isn had even
minimal regression tests :-( Anyone feel like writing some?

regards, tom lane

#3Rushabh Lathia
rushabh.lathia@gmail.com
In reply to: Tom Lane (#2)
Re: Server Crash into contrib module ISN into 64bit OS

I think we need to create ISBN type ( contrib/isn/isn.sql.in) with flag
PASSBYVALUE flag when flag USE_FLOAT8_BYVAL is set.

-Regards,
Rushabh

On Fri, Nov 28, 2008 at 10:29 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

"Rushabh Lathia" <rushabh.lathia@gmail.com> writes:

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

Hmm, this'd have been noticed sooner if contrib/isn had even
minimal regression tests :-( Anyone feel like writing some?

regards, tom lane

--
Rushabh Lathia