pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Add stack-overflow guards in set-operation planning. 6+ messages / 1 participants [nested] [flat]
* pgsql: Add stack-overflow guards in set-operation planning. @ 2018-01-28 18:39 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2018-01-28 18:39 UTC (permalink / raw) To: pgsql-committers Add stack-overflow guards in set-operation planning. create_plan_recurse lacked any stack depth check. This is not per our normal coding rules, but I'd supposed it was safe because earlier planner processing is more complex and presumably should eat more stack. But bug #15033 from Andrew Grossman shows this isn't true, at least not for queries having the form of a many-thousand-way INTERSECT stack. Further testing showed that recurse_set_operations is also capable of being crashed in this way, since it likewise will recurse to the bottom of a parsetree before calling any support functions that might themselves contain any stack checks. However, its stack consumption is only perhaps a third of create_plan_recurse's. It's possible that this particular problem with create_plan_recurse can only manifest in 9.6 and later, since before that we didn't build a Path tree for set operations. But having seen this example, I now have no faith in the proposition that create_plan_recurse doesn't need a stack check, so back-patch to all supported branches. Discussion: https://postgr.es/m/20180127050845.28812.58244@wrigleys.postgresql.org Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/35a528062cc8ccdb51bde6c672991ae64e970847 Modified Files -------------- src/backend/optimizer/plan/createplan.c | 3 +++ src/backend/optimizer/prep/prepunion.c | 3 +++ 2 files changed, 6 insertions(+) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Add stack-overflow guards in set-operation planning. @ 2018-01-28 18:39 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2018-01-28 18:39 UTC (permalink / raw) To: pgsql-committers Add stack-overflow guards in set-operation planning. create_plan_recurse lacked any stack depth check. This is not per our normal coding rules, but I'd supposed it was safe because earlier planner processing is more complex and presumably should eat more stack. But bug #15033 from Andrew Grossman shows this isn't true, at least not for queries having the form of a many-thousand-way INTERSECT stack. Further testing showed that recurse_set_operations is also capable of being crashed in this way, since it likewise will recurse to the bottom of a parsetree before calling any support functions that might themselves contain any stack checks. However, its stack consumption is only perhaps a third of create_plan_recurse's. It's possible that this particular problem with create_plan_recurse can only manifest in 9.6 and later, since before that we didn't build a Path tree for set operations. But having seen this example, I now have no faith in the proposition that create_plan_recurse doesn't need a stack check, so back-patch to all supported branches. Discussion: https://postgr.es/m/20180127050845.28812.58244@wrigleys.postgresql.org Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/1b2a3860d3ea81825e9bbad2c7dbf66db87445c1 Modified Files -------------- src/backend/optimizer/plan/createplan.c | 3 +++ src/backend/optimizer/prep/prepunion.c | 3 +++ 2 files changed, 6 insertions(+) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Add stack-overflow guards in set-operation planning. @ 2018-01-28 18:39 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2018-01-28 18:39 UTC (permalink / raw) To: pgsql-committers Add stack-overflow guards in set-operation planning. create_plan_recurse lacked any stack depth check. This is not per our normal coding rules, but I'd supposed it was safe because earlier planner processing is more complex and presumably should eat more stack. But bug #15033 from Andrew Grossman shows this isn't true, at least not for queries having the form of a many-thousand-way INTERSECT stack. Further testing showed that recurse_set_operations is also capable of being crashed in this way, since it likewise will recurse to the bottom of a parsetree before calling any support functions that might themselves contain any stack checks. However, its stack consumption is only perhaps a third of create_plan_recurse's. It's possible that this particular problem with create_plan_recurse can only manifest in 9.6 and later, since before that we didn't build a Path tree for set operations. But having seen this example, I now have no faith in the proposition that create_plan_recurse doesn't need a stack check, so back-patch to all supported branches. Discussion: https://postgr.es/m/20180127050845.28812.58244@wrigleys.postgresql.org Branch ------ REL9_6_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/4e9fb4bfe2e33aff941e29ec55972d68f4cdb69c Modified Files -------------- src/backend/optimizer/plan/createplan.c | 3 +++ src/backend/optimizer/prep/prepunion.c | 3 +++ 2 files changed, 6 insertions(+) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Add stack-overflow guards in set-operation planning. @ 2018-01-28 18:39 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2018-01-28 18:39 UTC (permalink / raw) To: pgsql-committers Add stack-overflow guards in set-operation planning. create_plan_recurse lacked any stack depth check. This is not per our normal coding rules, but I'd supposed it was safe because earlier planner processing is more complex and presumably should eat more stack. But bug #15033 from Andrew Grossman shows this isn't true, at least not for queries having the form of a many-thousand-way INTERSECT stack. Further testing showed that recurse_set_operations is also capable of being crashed in this way, since it likewise will recurse to the bottom of a parsetree before calling any support functions that might themselves contain any stack checks. However, its stack consumption is only perhaps a third of create_plan_recurse's. It's possible that this particular problem with create_plan_recurse can only manifest in 9.6 and later, since before that we didn't build a Path tree for set operations. But having seen this example, I now have no faith in the proposition that create_plan_recurse doesn't need a stack check, so back-patch to all supported branches. Discussion: https://postgr.es/m/20180127050845.28812.58244@wrigleys.postgresql.org Branch ------ REL9_5_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/e194f13838a57a79ba6b24f6c387fe3fad4e9f9e Modified Files -------------- src/backend/optimizer/plan/createplan.c | 3 +++ src/backend/optimizer/prep/prepunion.c | 3 +++ 2 files changed, 6 insertions(+) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Add stack-overflow guards in set-operation planning. @ 2018-01-28 18:39 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2018-01-28 18:39 UTC (permalink / raw) To: pgsql-committers Add stack-overflow guards in set-operation planning. create_plan_recurse lacked any stack depth check. This is not per our normal coding rules, but I'd supposed it was safe because earlier planner processing is more complex and presumably should eat more stack. But bug #15033 from Andrew Grossman shows this isn't true, at least not for queries having the form of a many-thousand-way INTERSECT stack. Further testing showed that recurse_set_operations is also capable of being crashed in this way, since it likewise will recurse to the bottom of a parsetree before calling any support functions that might themselves contain any stack checks. However, its stack consumption is only perhaps a third of create_plan_recurse's. It's possible that this particular problem with create_plan_recurse can only manifest in 9.6 and later, since before that we didn't build a Path tree for set operations. But having seen this example, I now have no faith in the proposition that create_plan_recurse doesn't need a stack check, so back-patch to all supported branches. Discussion: https://postgr.es/m/20180127050845.28812.58244@wrigleys.postgresql.org Branch ------ REL9_4_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/06efc5cf53b96ef5b9c10995fc7c9ec06c1b4846 Modified Files -------------- src/backend/optimizer/plan/createplan.c | 3 +++ src/backend/optimizer/prep/prepunion.c | 3 +++ 2 files changed, 6 insertions(+) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Add stack-overflow guards in set-operation planning. @ 2018-01-28 18:39 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2018-01-28 18:39 UTC (permalink / raw) To: pgsql-committers Add stack-overflow guards in set-operation planning. create_plan_recurse lacked any stack depth check. This is not per our normal coding rules, but I'd supposed it was safe because earlier planner processing is more complex and presumably should eat more stack. But bug #15033 from Andrew Grossman shows this isn't true, at least not for queries having the form of a many-thousand-way INTERSECT stack. Further testing showed that recurse_set_operations is also capable of being crashed in this way, since it likewise will recurse to the bottom of a parsetree before calling any support functions that might themselves contain any stack checks. However, its stack consumption is only perhaps a third of create_plan_recurse's. It's possible that this particular problem with create_plan_recurse can only manifest in 9.6 and later, since before that we didn't build a Path tree for set operations. But having seen this example, I now have no faith in the proposition that create_plan_recurse doesn't need a stack check, so back-patch to all supported branches. Discussion: https://postgr.es/m/20180127050845.28812.58244@wrigleys.postgresql.org Branch ------ REL9_3_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/c03fc84626beca122d4aafd77fe6eb508d98edb7 Modified Files -------------- src/backend/optimizer/plan/createplan.c | 3 +++ src/backend/optimizer/prep/prepunion.c | 3 +++ 2 files changed, 6 insertions(+) ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2018-01-28 18:39 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2018-01-28 18:39 pgsql: Add stack-overflow guards in set-operation planning. Tom Lane <tgl@sss.pgh.pa.us> 2018-01-28 18:39 pgsql: Add stack-overflow guards in set-operation planning. Tom Lane <tgl@sss.pgh.pa.us> 2018-01-28 18:39 pgsql: Add stack-overflow guards in set-operation planning. Tom Lane <tgl@sss.pgh.pa.us> 2018-01-28 18:39 pgsql: Add stack-overflow guards in set-operation planning. Tom Lane <tgl@sss.pgh.pa.us> 2018-01-28 18:39 pgsql: Add stack-overflow guards in set-operation planning. Tom Lane <tgl@sss.pgh.pa.us> 2018-01-28 18:39 pgsql: Add stack-overflow guards in set-operation planning. Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox