Re: Intermittent bug - Mailing list pgsql-hackers

From Thomas Hallgren
Subject Re: Intermittent bug
Date
Msg-id thhal-0WoeBAh0VcC4LWR8wt0KvXOAhvkqVqG@mailblocks.com
Whole thread Raw
In response to Intermittent bug  (Thomas Hallgren <thhal@mailblocks.com>)
Responses Re: Intermittent bug  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
After some pretty tedious assembly debugging I've managed to locate the 
source of my problem. It is probably similar to a bug involving 
MemoryContext life cycle on IMMUTABLE functions that I struggled with 
last winter (later fixed by Tom).

This is what happens:

I have an function declared as IMMUTABLE that returns a SETOF tuples. I 
palloc some data using the context->multi_call_memory_context during the 
SRF_IS_FIRSTCALL phase and I assign that data to the context->user_fctx.

I obtain the context again using SRF_PERCALL_SETUP() and from that my 
palloc'ed data. I have verified that I get the exact same pointer. I do, 
but the memory that it points to is no longer accessible! I get an 
access fault and I can't even display that memory in the debugger. This 
tells me that the memory is no longer bound to the process, it must have 
been free'd up.

What life span does the context->multi_call_memory_context have in case 
of IMMUTABLE functions that returns SETOF?

Regards,
Thomas Hallgren




pgsql-hackers by date:

Previous
From: Adam Witney
Date:
Subject: Re: problem installing 8.0.0beta5 on OS X 10.3
Next
From: Alvaro Herrera
Date:
Subject: Explain output: wrong row count?