pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Save/restore SPI's global variables in SPI_connect() and SPI_fin 7+ messages / 1 participants [nested] [flat]
* pgsql: Save/restore SPI's global variables in SPI_connect() and SPI_fin @ 2018-09-08 00:10 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2018-09-08 00:10 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Save/restore SPI's global variables in SPI_connect() and SPI_finish(). This patch removes two sources of interference between nominally independent functions when one SPI-using function calls another, perhaps without knowing that it does so. Chapman Flack pointed out that xml.c's query_to_xml_internal() expects SPI_tuptable and SPI_processed to stay valid across datatype output function calls; but it's possible that such a call could involve re-entrant use of SPI. It seems likely that there are similar hazards elsewhere, if not in the core code then in third-party SPI users. Previously SPI_finish() reset SPI's API globals to zeroes/nulls, which would typically make for a crash in such a situation. Restoring them to the values they had at SPI_connect() seems like a considerably more useful behavior, and it still meets the design goal of not leaving any dangling pointers to tuple tables of the function being exited. Also, cause SPI_connect() to reset these variables to zeroes/nulls after saving them. This prevents interference in the opposite direction: it's possible that a SPI-using function that's only ever been tested standalone contains assumptions that these variables start out as zeroes. That was the case as long as you were the outermost SPI user, but not so much for an inner user. Now it's consistent. Report and fix suggestion by Chapman Flack, actual patch by me. Back-patch to all supported branches. Discussion: https://postgr.es/m/9fa25bef-2e4f-1c32-22a4-3ad0723c4a17@anastigmatix.net Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/825f10fbda7a5d8a48d187b8193160e5e44e4011 Modified Files -------------- src/backend/executor/spi.c | 42 ++++++++++++++++++++++++++++++++--------- src/include/executor/spi_priv.h | 6 ++++++ 2 files changed, 39 insertions(+), 9 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Save/restore SPI's global variables in SPI_connect() and SPI_fin @ 2018-09-08 00:10 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2018-09-08 00:10 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Save/restore SPI's global variables in SPI_connect() and SPI_finish(). This patch removes two sources of interference between nominally independent functions when one SPI-using function calls another, perhaps without knowing that it does so. Chapman Flack pointed out that xml.c's query_to_xml_internal() expects SPI_tuptable and SPI_processed to stay valid across datatype output function calls; but it's possible that such a call could involve re-entrant use of SPI. It seems likely that there are similar hazards elsewhere, if not in the core code then in third-party SPI users. Previously SPI_finish() reset SPI's API globals to zeroes/nulls, which would typically make for a crash in such a situation. Restoring them to the values they had at SPI_connect() seems like a considerably more useful behavior, and it still meets the design goal of not leaving any dangling pointers to tuple tables of the function being exited. Also, cause SPI_connect() to reset these variables to zeroes/nulls after saving them. This prevents interference in the opposite direction: it's possible that a SPI-using function that's only ever been tested standalone contains assumptions that these variables start out as zeroes. That was the case as long as you were the outermost SPI user, but not so much for an inner user. Now it's consistent. Report and fix suggestion by Chapman Flack, actual patch by me. Back-patch to all supported branches. Discussion: https://postgr.es/m/9fa25bef-2e4f-1c32-22a4-3ad0723c4a17@anastigmatix.net Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/3985b75dca6d1101cc4cb6e78456dc6c5f72fcac Modified Files -------------- src/backend/executor/spi.c | 42 ++++++++++++++++++++++++++++++++--------- src/include/executor/spi_priv.h | 6 ++++++ 2 files changed, 39 insertions(+), 9 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Save/restore SPI's global variables in SPI_connect() and SPI_fin @ 2018-09-08 00:10 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2018-09-08 00:10 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Save/restore SPI's global variables in SPI_connect() and SPI_finish(). This patch removes two sources of interference between nominally independent functions when one SPI-using function calls another, perhaps without knowing that it does so. Chapman Flack pointed out that xml.c's query_to_xml_internal() expects SPI_tuptable and SPI_processed to stay valid across datatype output function calls; but it's possible that such a call could involve re-entrant use of SPI. It seems likely that there are similar hazards elsewhere, if not in the core code then in third-party SPI users. Previously SPI_finish() reset SPI's API globals to zeroes/nulls, which would typically make for a crash in such a situation. Restoring them to the values they had at SPI_connect() seems like a considerably more useful behavior, and it still meets the design goal of not leaving any dangling pointers to tuple tables of the function being exited. Also, cause SPI_connect() to reset these variables to zeroes/nulls after saving them. This prevents interference in the opposite direction: it's possible that a SPI-using function that's only ever been tested standalone contains assumptions that these variables start out as zeroes. That was the case as long as you were the outermost SPI user, but not so much for an inner user. Now it's consistent. Report and fix suggestion by Chapman Flack, actual patch by me. Back-patch to all supported branches. Discussion: https://postgr.es/m/9fa25bef-2e4f-1c32-22a4-3ad0723c4a17@anastigmatix.net Branch ------ REL9_5_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/0254aa83b57abb4e971f6b225cc4678c782fdf51 Modified Files -------------- src/backend/executor/spi.c | 42 ++++++++++++++++++++++++++++++++--------- src/include/executor/spi_priv.h | 6 ++++++ 2 files changed, 39 insertions(+), 9 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Save/restore SPI's global variables in SPI_connect() and SPI_fin @ 2018-09-08 00:10 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2018-09-08 00:10 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Save/restore SPI's global variables in SPI_connect() and SPI_finish(). This patch removes two sources of interference between nominally independent functions when one SPI-using function calls another, perhaps without knowing that it does so. Chapman Flack pointed out that xml.c's query_to_xml_internal() expects SPI_tuptable and SPI_processed to stay valid across datatype output function calls; but it's possible that such a call could involve re-entrant use of SPI. It seems likely that there are similar hazards elsewhere, if not in the core code then in third-party SPI users. Previously SPI_finish() reset SPI's API globals to zeroes/nulls, which would typically make for a crash in such a situation. Restoring them to the values they had at SPI_connect() seems like a considerably more useful behavior, and it still meets the design goal of not leaving any dangling pointers to tuple tables of the function being exited. Also, cause SPI_connect() to reset these variables to zeroes/nulls after saving them. This prevents interference in the opposite direction: it's possible that a SPI-using function that's only ever been tested standalone contains assumptions that these variables start out as zeroes. That was the case as long as you were the outermost SPI user, but not so much for an inner user. Now it's consistent. Report and fix suggestion by Chapman Flack, actual patch by me. Back-patch to all supported branches. Discussion: https://postgr.es/m/9fa25bef-2e4f-1c32-22a4-3ad0723c4a17@anastigmatix.net Branch ------ REL9_4_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/d2003339c3969d93750104fc41b5ab27393a952b Modified Files -------------- src/backend/executor/spi.c | 42 ++++++++++++++++++++++++++++++++--------- src/include/executor/spi_priv.h | 6 ++++++ 2 files changed, 39 insertions(+), 9 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Save/restore SPI's global variables in SPI_connect() and SPI_fin @ 2018-09-08 00:10 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2018-09-08 00:10 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Save/restore SPI's global variables in SPI_connect() and SPI_finish(). This patch removes two sources of interference between nominally independent functions when one SPI-using function calls another, perhaps without knowing that it does so. Chapman Flack pointed out that xml.c's query_to_xml_internal() expects SPI_tuptable and SPI_processed to stay valid across datatype output function calls; but it's possible that such a call could involve re-entrant use of SPI. It seems likely that there are similar hazards elsewhere, if not in the core code then in third-party SPI users. Previously SPI_finish() reset SPI's API globals to zeroes/nulls, which would typically make for a crash in such a situation. Restoring them to the values they had at SPI_connect() seems like a considerably more useful behavior, and it still meets the design goal of not leaving any dangling pointers to tuple tables of the function being exited. Also, cause SPI_connect() to reset these variables to zeroes/nulls after saving them. This prevents interference in the opposite direction: it's possible that a SPI-using function that's only ever been tested standalone contains assumptions that these variables start out as zeroes. That was the case as long as you were the outermost SPI user, but not so much for an inner user. Now it's consistent. Report and fix suggestion by Chapman Flack, actual patch by me. Back-patch to all supported branches. Discussion: https://postgr.es/m/9fa25bef-2e4f-1c32-22a4-3ad0723c4a17@anastigmatix.net Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/361844fe561f6898d90a10382705ad968929a4b2 Modified Files -------------- src/backend/executor/spi.c | 42 ++++++++++++++++++++++++++++++++--------- src/include/executor/spi_priv.h | 6 ++++++ 2 files changed, 39 insertions(+), 9 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Save/restore SPI's global variables in SPI_connect() and SPI_fin @ 2018-09-08 00:10 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2018-09-08 00:10 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Save/restore SPI's global variables in SPI_connect() and SPI_finish(). This patch removes two sources of interference between nominally independent functions when one SPI-using function calls another, perhaps without knowing that it does so. Chapman Flack pointed out that xml.c's query_to_xml_internal() expects SPI_tuptable and SPI_processed to stay valid across datatype output function calls; but it's possible that such a call could involve re-entrant use of SPI. It seems likely that there are similar hazards elsewhere, if not in the core code then in third-party SPI users. Previously SPI_finish() reset SPI's API globals to zeroes/nulls, which would typically make for a crash in such a situation. Restoring them to the values they had at SPI_connect() seems like a considerably more useful behavior, and it still meets the design goal of not leaving any dangling pointers to tuple tables of the function being exited. Also, cause SPI_connect() to reset these variables to zeroes/nulls after saving them. This prevents interference in the opposite direction: it's possible that a SPI-using function that's only ever been tested standalone contains assumptions that these variables start out as zeroes. That was the case as long as you were the outermost SPI user, but not so much for an inner user. Now it's consistent. Report and fix suggestion by Chapman Flack, actual patch by me. Back-patch to all supported branches. Discussion: https://postgr.es/m/9fa25bef-2e4f-1c32-22a4-3ad0723c4a17@anastigmatix.net Branch ------ REL9_3_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/92f0c5083db544a90a281775ffc92390046dd97e Modified Files -------------- src/backend/executor/spi.c | 42 ++++++++++++++++++++++++++++++++--------- src/include/executor/spi_priv.h | 6 ++++++ 2 files changed, 39 insertions(+), 9 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Save/restore SPI's global variables in SPI_connect() and SPI_fin @ 2018-09-08 00:10 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2018-09-08 00:10 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Save/restore SPI's global variables in SPI_connect() and SPI_finish(). This patch removes two sources of interference between nominally independent functions when one SPI-using function calls another, perhaps without knowing that it does so. Chapman Flack pointed out that xml.c's query_to_xml_internal() expects SPI_tuptable and SPI_processed to stay valid across datatype output function calls; but it's possible that such a call could involve re-entrant use of SPI. It seems likely that there are similar hazards elsewhere, if not in the core code then in third-party SPI users. Previously SPI_finish() reset SPI's API globals to zeroes/nulls, which would typically make for a crash in such a situation. Restoring them to the values they had at SPI_connect() seems like a considerably more useful behavior, and it still meets the design goal of not leaving any dangling pointers to tuple tables of the function being exited. Also, cause SPI_connect() to reset these variables to zeroes/nulls after saving them. This prevents interference in the opposite direction: it's possible that a SPI-using function that's only ever been tested standalone contains assumptions that these variables start out as zeroes. That was the case as long as you were the outermost SPI user, but not so much for an inner user. Now it's consistent. Report and fix suggestion by Chapman Flack, actual patch by me. Back-patch to all supported branches. Discussion: https://postgr.es/m/9fa25bef-2e4f-1c32-22a4-3ad0723c4a17@anastigmatix.net Branch ------ REL9_6_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/82ebf39fcb25236b60f05e4483d86cb4144fce8a Modified Files -------------- src/backend/executor/spi.c | 42 ++++++++++++++++++++++++++++++++--------- src/include/executor/spi_priv.h | 6 ++++++ 2 files changed, 39 insertions(+), 9 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2018-09-08 00:10 UTC | newest] Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2018-09-08 00:10 pgsql: Save/restore SPI's global variables in SPI_connect() and SPI_fin Tom Lane <tgl@sss.pgh.pa.us> 2018-09-08 00:10 pgsql: Save/restore SPI's global variables in SPI_connect() and SPI_fin Tom Lane <tgl@sss.pgh.pa.us> 2018-09-08 00:10 pgsql: Save/restore SPI's global variables in SPI_connect() and SPI_fin Tom Lane <tgl@sss.pgh.pa.us> 2018-09-08 00:10 pgsql: Save/restore SPI's global variables in SPI_connect() and SPI_fin Tom Lane <tgl@sss.pgh.pa.us> 2018-09-08 00:10 pgsql: Save/restore SPI's global variables in SPI_connect() and SPI_fin Tom Lane <tgl@sss.pgh.pa.us> 2018-09-08 00:10 pgsql: Save/restore SPI's global variables in SPI_connect() and SPI_fin Tom Lane <tgl@sss.pgh.pa.us> 2018-09-08 00:10 pgsql: Save/restore SPI's global variables in SPI_connect() and SPI_fin 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