From: | "Merlin Moncure" <mmoncure(at)gmail(dot)com> |
---|---|
To: | "Postgres General" <pgsql-general(at)postgresql(dot)org> |
Subject: | SPI dumping core on large palloc |
Date: | 2007-10-08 14:18:00 |
Message-ID: | b42b73150710080718j114f37d7kbad56ec16aab413f@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I'm having an issue inside a SPI routine that is giving me crashes.
I'm curious if this is a backend problem or something that I am doing
improperly. The following SPI routine dumps core for large, but
reasonable allocations:
/* testing function. just makes bytea a of input len */
Datum _genbytes(PG_FUNCTION_ARGS)
{
int nbytes = PG_GETARG_INT32(0);
bytea* out;
if(SPI_connect() != SPI_OK_CONNECT)
MAKE_PGERROR("SPI_connect");
PG_NEW_BYTEA(out, nbytes); // see below
SPI_finish();
PG_RETURN_BYTEA_P(out);
}
#define PG_NEW_BYTEA(_bytea, _len) do{ \
int __l = (int)(_len) + VARHDRSZ; \
_bytea = (bytea *)palloc(__l); \
SET_VARSIZE(_bytea, __l); \
} while(0)
If SPI connect/finish is not inside the function (this is a reduced
example), I do not get the crash. If the bytea allocation is _before_
SPI connect, no crash, and no crash for small allocations.
I noticed in some of the contrib code that some allocations look like
they are being aligned. Am I doing anything wrong here?
merlin
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2007-10-08 14:37:26 | Re: SPI dumping core on large palloc |
Previous Message | Douglas McNaught | 2007-10-08 13:00:59 | Re: starting a stored procedure+rule AFTER an insert |