Re: BUG #16213: segfault when running a query
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-hackers@lists.postgresql.org
Cc: matt.jibson@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2020-01-17T18:29:54Z
Lists: pgsql-bugs, pgsql-hackers
Attachments
- fix-for-hashed-subplan-in-VALUES-2.patch (text/x-diff) patch
I wrote: > PG Bug reporting form <noreply@postgresql.org> writes: >> The above query produces an error in the server log: >> LOG: server process (PID 108) was terminated by signal 11: Segmentation >> fault > The direct cause of the crash is that by the time we get to ExecutorEnd, > there are dangling pointers in the es_tupleTable list. After further reflection, I'm totally dissatisfied with the quick-hack patch I posted last night. I think that what this example demonstrates is that my fix (in commit 9b63c13f0) for bug #14924 in fact does not work: the subPlan list is not the only way in which a SubPlan connects up to the outer plan level. I have no faith that the es_tupleTable list is the only other way, either, or that we won't create more in future. I think what we have to do here is revert 9b63c13f0, going back to the previous policy of passing down parent = NULL to the transient subexpressions, so that there is a strong guarantee that there aren't any unwanted connections between short-lived and longer-lived state. And then we need some other solution for making SubPlans in VALUES lists work. The best bet seems to be what I speculated about in that commit message: initialize the expressions for VALUES rows that contain SubPlans normally at executor startup, and use the trick with short-lived expression state only for VALUES rows that don't contain any SubPlans. I think that the case we're worried about with long VALUES lists is not likely to involve any SubPlans, so that this shouldn't be too awful for memory consumption. Another benefit of doing it like this is that SubPlans in the VALUES lists are reported normally by EXPLAIN, while the previous hack caused them to be missing from the output. Objections, better ideas? regards, tom lane
Commits
-
Repair more failures with SubPlans in multi-row VALUES lists.
- eb9d1f0504a6 9.4.26 landed
- 3964722780d8 9.5.21 landed
- 45f03cfa56c8 9.6.17 landed
- 167fd022ff33 10.12 landed
- d8e877b869cb 11.7 landed
- 2e2646060e18 12.2 landed
- 41c6f9db25b5 13.0 landed
-
Repair failure with SubPlans in multi-row VALUES lists.
- 9b63c13f0a21 11.0 cited