From: | Thomas Hallgren <thhal(at)mailblocks(dot)com> |
---|---|
To: | "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Intermittent bug |
Date: | 2004-11-25 14:40:24 |
Message-ID: | thhal-0WoeBAh0VcC4LWR8wt0KvXOAhvkqVqG@mailblocks.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2004-11-25 16:11:22 | Explain output: wrong row count? |
Previous Message | Alvaro Herrera | 2004-11-25 14:22:35 | Re: Beta5 now Available |