Re: BUG #18360: Invalid memory access occurs when using geqo
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: exclusion@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Date: 2024-02-23T19:33:49Z
Lists: pgsql-bugs
Attachments
- 0001-fix-bug-18360.patch (text/x-diff) patch 0001
I wrote: > Indeed. Curiously, the in_operators list, which I thought was > parallel to that, seems fine. Anyway, something's being careless > about which context it creates that data structure in. Shouldn't > be too hard to fix. The problem seems to arise from build_child_join_sjinfo(), which makes a translated version of the semi_rhs_exprs that is later propagated into a UniquePath for a base relation. This breaks GEQO's intention that base-relation structs will be long-lived while only join-relation data is short-lived. (in_operators is not modified so the original long-lived list is used for that, explaining why it's not trashed at the same time.) The simplest fix is as attached: just do a quick copyObject in create_unique_path. That's rather ugly, but create_unique_path is already taking explicit responsibility for the context that the Path is built in, so it doesn't quite exceed my threshold of pain. (The alternative of making build_child_join_sjinfo force its output to be long-lived doesn't look good: that gets invoked quite a few times during a GEQO cycle.) I chose to make it copy the in_operators list as well, even though that's not minimally necessary to fix the bug --- it would look odd if we didn't, and the copy is pretty cheap since it's only a short integer list. regards, tom lane
Commits
-
Avoid dangling-pointer problem with partitionwise joins under GEQO.
- ef0333e67633 16.3 landed
- cf807eba5dc4 12.19 landed
- cbeb45527513 14.12 landed
- a6b2a51e16d7 17.0 landed
- 9061fd23c28f 13.15 landed
- 37bbe3d3acd6 15.7 landed