From: | Stephen Woodbridge <woodbri(at)swoodbridge(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Need help with TRAP: FailedAssertion("!(context != CurrentMemoryContext)" |
Date: | 2013-04-21 00:21:01 |
Message-ID: | 517330ED.60601@swoodbridge.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 4/20/2013 5:00 PM, Andres Freund wrote:
> On 2013-04-20 16:32:36 -0400, Stephen Woodbridge wrote:
>> Hi all,
>>
>> I have been writing pg extensions for a while but I just ran into a problem
>> that has me stumped.
>>
>> I have code for a SRF and it works fine on pg 9.2.2 on linux, but fails with
>> am error in the logfile.
>>
>> TRAP: FailedAssertion("!(context != CurrentMemoryContext)", File: "mcxt.c",
>> Line: 172)
>
> This means that the current memory context is being deleted. Are you
> doing that or did you maybe MemoryContextSwitchTo to some context but
> not back?
Andres,
Thank you for your reply. The frustrating thing about this is the same
source works fine in Linux. So here is the pseudo code of my source
removing non pgsql stuff and not expected to be runnable:
PG_FUNCTION_INFO_V1(myfunc);
Datum myfunc(PG_FUNCTION_ARGS)
{
if (SRF_IS_FIRSTCALL()) {
funcctx = SRF_FIRSTCALL_INIT();
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
SPIcode = SPI_connect();
// execute some SPI queries and load some structures
// execute a query and save the tuptable and
// other stuff in funcctx->user_fctx
MemoryContextSwitchTo(oldcontext);
}
funcctx = SRF_PERCALL_SETUP();
if (call_cntr < max_calls) {
// process a row in my saved tuptable
SRF_RETURN_NEXT(funcctx, result)
}
else { // we are all done cleanup
// free stuff from my library
SPI_freetuptable(my_tuptable);
SPIcode = SPI_finish(); // <<<<< CRASHES HERE >>>>>
SRF_RETURN_DONE(funcctx);
}
}
So, like I said, it runs on Linux not in MinGW on windows. Anyway, did I
mess up the memory context switching? Is there a way I can force the
context to the appropriate place.
Thanks,
-Steve
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen Woodbridge | 2013-04-21 02:17:39 | Re: Need help with TRAP: FailedAssertion("!(context != CurrentMemoryContext)" |
Previous Message | Andres Freund | 2013-04-20 21:00:32 | Re: Need help with TRAP: FailedAssertion("!(context != CurrentMemoryContext)" |