Re: Need help with TRAP: FailedAssertion("!(context != CurrentMemoryContext)"
От | Stephen Woodbridge |
---|---|
Тема | Re: Need help with TRAP: FailedAssertion("!(context != CurrentMemoryContext)" |
Дата | |
Msg-id | 517330ED.60601@swoodbridge.com обсуждение исходный текст |
Ответ на | Re: Need help with TRAP: FailedAssertion("!(context != CurrentMemoryContext)" (Andres Freund <andres@2ndquadrant.com>) |
Ответы |
Re: Need help with TRAP: FailedAssertion("!(context !=
CurrentMemoryContext)"
Re: Need help with TRAP: FailedAssertion("!(context != CurrentMemoryContext)" |
Список | 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 stuffin 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
В списке pgsql-hackers по дате отправления: