Re: Improper usage of MemoryContext in nodeSubplan.c for buildSubPlanHash() function. This maybe causes allocate memory failed.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Tao Ma" <feng_eden(at)163(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Improper usage of MemoryContext in nodeSubplan.c for buildSubPlanHash() function. This maybe causes allocate memory failed.
Date: 2010-07-28 03:18:18
Message-ID: 22050.1280287098@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Tao Ma" <feng_eden(at)163(dot)com> writes:
> This is a potential memory error in nodeSubplan.c or execGrouping.c
> Using select '1'::TEXT IN ((SELECT '1'::NAME) UNION ALL SELECT '1'::NAME);
> to reproduce this bug.
> ...
> To fix this problem, we can use another memory context to passin
> BuildTupleHashTable() as the hashtable's tempcxt, or use other memory
> context as hash table's tempcxt or other ways.

Yeah, I think you're right --- we can't get away with reusing the
innerecontext's per-tuple context for the hashtable temp contexts.
The best solution is probably to make an additional context that
does nothing but act as the hashtable temp context.

This bug's been there a long time :-(. Surprising that no one found it
before. It would be mostly masked in a non-assert build, but not
entirely, I think.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2010-07-28 03:43:37 Re: Performance Enhancement/Fix for Array Utility Functions
Previous Message David E. Wheeler 2010-07-28 02:55:18 Re: Toward a column reorder solution