pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix broken logic for reporting PL/Python function names in errco
6+ messages / 1 participants
[nested] [flat]

* pgsql: Fix broken logic for reporting PL/Python function names in errco
@ 2018-02-14 19:47 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2018-02-14 19:47 UTC (permalink / raw)
  To: pgsql-committers

Fix broken logic for reporting PL/Python function names in errcontext.

plpython_error_callback() reported the name of the function associated
with the topmost PL/Python execution context.  This was not merely
wrong if there were nested PL/Python contexts, but it risked a core
dump if the topmost one is an inline code block rather than a named
function.  That will have proname = NULL, and so we were passing a NULL
pointer to snprintf("%s").  It seems that none of the PL/Python-testing
machines in the buildfarm will dump core for that, but some platforms do,
as reported by Marina Polyakova.

Investigation finds that there actually is an existing regression test
that used to prove that the behavior was wrong, though apparently no one
had noticed that it was printing the wrong function name.  It stopped
showing the problem in 9.6 when we adjusted psql to not print CONTEXT
by default for NOTICE messages.  The problem is masked (if your platform
avoids the core dump) in error cases, because PL/Python will throw away
the originally generated error info in favor of a new traceback produced
at the outer level.

Repair by using ErrorContextCallback.arg to pass the correct context to
the error callback.  Add a regression test illustrating correct behavior.

Back-patch to all supported branches, since they're all broken this way.

Discussion: https://postgr.es/m/156b989dbc6fe7c4d3223cf51da61195@postgrespro.ru

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e748e902def40ee52d1ef0b770fd24aa0835e304

Modified Files
--------------
src/pl/plpython/expected/plpython_error.out   | 23 ++++++++++++
src/pl/plpython/expected/plpython_error_0.out | 23 ++++++++++++
src/pl/plpython/expected/plpython_error_5.out | 23 ++++++++++++
src/pl/plpython/plpy_main.c                   | 52 +++++++++++++--------------
src/pl/plpython/plpy_procedure.c              |  4 +--
src/pl/plpython/sql/plpython_error.sql        | 16 +++++++++
6 files changed, 112 insertions(+), 29 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix broken logic for reporting PL/Python function names in errco
@ 2018-02-14 19:47 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2018-02-14 19:47 UTC (permalink / raw)
  To: pgsql-committers

Fix broken logic for reporting PL/Python function names in errcontext.

plpython_error_callback() reported the name of the function associated
with the topmost PL/Python execution context.  This was not merely
wrong if there were nested PL/Python contexts, but it risked a core
dump if the topmost one is an inline code block rather than a named
function.  That will have proname = NULL, and so we were passing a NULL
pointer to snprintf("%s").  It seems that none of the PL/Python-testing
machines in the buildfarm will dump core for that, but some platforms do,
as reported by Marina Polyakova.

Investigation finds that there actually is an existing regression test
that used to prove that the behavior was wrong, though apparently no one
had noticed that it was printing the wrong function name.  It stopped
showing the problem in 9.6 when we adjusted psql to not print CONTEXT
by default for NOTICE messages.  The problem is masked (if your platform
avoids the core dump) in error cases, because PL/Python will throw away
the originally generated error info in favor of a new traceback produced
at the outer level.

Repair by using ErrorContextCallback.arg to pass the correct context to
the error callback.  Add a regression test illustrating correct behavior.

Back-patch to all supported branches, since they're all broken this way.

Discussion: https://postgr.es/m/156b989dbc6fe7c4d3223cf51da61195@postgrespro.ru

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/4081e1136178937e944170a011037f804d2673d8

Modified Files
--------------
src/pl/plpython/expected/plpython_error.out   | 23 ++++++++++++
src/pl/plpython/expected/plpython_error_0.out | 23 ++++++++++++
src/pl/plpython/expected/plpython_error_5.out | 23 ++++++++++++
src/pl/plpython/plpy_main.c                   | 52 +++++++++++++--------------
src/pl/plpython/plpy_procedure.c              |  4 +--
src/pl/plpython/sql/plpython_error.sql        | 16 +++++++++
6 files changed, 112 insertions(+), 29 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix broken logic for reporting PL/Python function names in errco
@ 2018-02-14 19:47 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2018-02-14 19:47 UTC (permalink / raw)
  To: pgsql-committers

Fix broken logic for reporting PL/Python function names in errcontext.

plpython_error_callback() reported the name of the function associated
with the topmost PL/Python execution context.  This was not merely
wrong if there were nested PL/Python contexts, but it risked a core
dump if the topmost one is an inline code block rather than a named
function.  That will have proname = NULL, and so we were passing a NULL
pointer to snprintf("%s").  It seems that none of the PL/Python-testing
machines in the buildfarm will dump core for that, but some platforms do,
as reported by Marina Polyakova.

Investigation finds that there actually is an existing regression test
that used to prove that the behavior was wrong, though apparently no one
had noticed that it was printing the wrong function name.  It stopped
showing the problem in 9.6 when we adjusted psql to not print CONTEXT
by default for NOTICE messages.  The problem is masked (if your platform
avoids the core dump) in error cases, because PL/Python will throw away
the originally generated error info in favor of a new traceback produced
at the outer level.

Repair by using ErrorContextCallback.arg to pass the correct context to
the error callback.  Add a regression test illustrating correct behavior.

Back-patch to all supported branches, since they're all broken this way.

Discussion: https://postgr.es/m/156b989dbc6fe7c4d3223cf51da61195@postgrespro.ru

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/0a2381d13f77c0f9f6aa30fa1a81e55aa58e7190

Modified Files
--------------
src/pl/plpython/expected/plpython_error.out   | 23 ++++++++++++
src/pl/plpython/expected/plpython_error_0.out | 23 ++++++++++++
src/pl/plpython/expected/plpython_error_5.out | 23 ++++++++++++
src/pl/plpython/plpy_main.c                   | 52 +++++++++++++--------------
src/pl/plpython/plpy_procedure.c              |  4 +--
src/pl/plpython/sql/plpython_error.sql        | 16 +++++++++
6 files changed, 112 insertions(+), 29 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix broken logic for reporting PL/Python function names in errco
@ 2018-02-14 19:47 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2018-02-14 19:47 UTC (permalink / raw)
  To: pgsql-committers

Fix broken logic for reporting PL/Python function names in errcontext.

plpython_error_callback() reported the name of the function associated
with the topmost PL/Python execution context.  This was not merely
wrong if there were nested PL/Python contexts, but it risked a core
dump if the topmost one is an inline code block rather than a named
function.  That will have proname = NULL, and so we were passing a NULL
pointer to snprintf("%s").  It seems that none of the PL/Python-testing
machines in the buildfarm will dump core for that, but some platforms do,
as reported by Marina Polyakova.

Investigation finds that there actually is an existing regression test
that used to prove that the behavior was wrong, though apparently no one
had noticed that it was printing the wrong function name.  It stopped
showing the problem in 9.6 when we adjusted psql to not print CONTEXT
by default for NOTICE messages.  The problem is masked (if your platform
avoids the core dump) in error cases, because PL/Python will throw away
the originally generated error info in favor of a new traceback produced
at the outer level.

Repair by using ErrorContextCallback.arg to pass the correct context to
the error callback.  Add a regression test illustrating correct behavior.

Back-patch to all supported branches, since they're all broken this way.

Discussion: https://postgr.es/m/156b989dbc6fe7c4d3223cf51da61195@postgrespro.ru

Branch
------
REL9_5_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/db1c597f3c331f57201a6fbfab72b93fd98f9945

Modified Files
--------------
src/pl/plpython/expected/plpython_error.out        | 23 ++++++++++
src/pl/plpython/expected/plpython_error_0.out      | 23 ++++++++++
src/pl/plpython/expected/plpython_error_5.out      | 23 ++++++++++
.../plpython/expected/plpython_subtransaction.out  |  2 +-
src/pl/plpython/plpy_main.c                        | 52 +++++++++++-----------
src/pl/plpython/plpy_procedure.c                   |  4 +-
src/pl/plpython/sql/plpython_error.sql             | 16 +++++++
7 files changed, 113 insertions(+), 30 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix broken logic for reporting PL/Python function names in errco
@ 2018-02-14 19:47 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2018-02-14 19:47 UTC (permalink / raw)
  To: pgsql-committers

Fix broken logic for reporting PL/Python function names in errcontext.

plpython_error_callback() reported the name of the function associated
with the topmost PL/Python execution context.  This was not merely
wrong if there were nested PL/Python contexts, but it risked a core
dump if the topmost one is an inline code block rather than a named
function.  That will have proname = NULL, and so we were passing a NULL
pointer to snprintf("%s").  It seems that none of the PL/Python-testing
machines in the buildfarm will dump core for that, but some platforms do,
as reported by Marina Polyakova.

Investigation finds that there actually is an existing regression test
that used to prove that the behavior was wrong, though apparently no one
had noticed that it was printing the wrong function name.  It stopped
showing the problem in 9.6 when we adjusted psql to not print CONTEXT
by default for NOTICE messages.  The problem is masked (if your platform
avoids the core dump) in error cases, because PL/Python will throw away
the originally generated error info in favor of a new traceback produced
at the outer level.

Repair by using ErrorContextCallback.arg to pass the correct context to
the error callback.  Add a regression test illustrating correct behavior.

Back-patch to all supported branches, since they're all broken this way.

Discussion: https://postgr.es/m/156b989dbc6fe7c4d3223cf51da61195@postgrespro.ru

Branch
------
REL9_4_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/bd871863787bc09ababd7e81a189492a1cd08803

Modified Files
--------------
src/pl/plpython/expected/plpython_error.out        | 23 ++++++++++
src/pl/plpython/expected/plpython_error_0.out      | 23 ++++++++++
src/pl/plpython/expected/plpython_error_5.out      | 23 ++++++++++
.../plpython/expected/plpython_subtransaction.out  |  2 +-
src/pl/plpython/plpy_main.c                        | 52 +++++++++++-----------
src/pl/plpython/plpy_procedure.c                   |  4 +-
src/pl/plpython/sql/plpython_error.sql             | 16 +++++++
7 files changed, 113 insertions(+), 30 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix broken logic for reporting PL/Python function names in errco
@ 2018-02-14 19:47 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2018-02-14 19:47 UTC (permalink / raw)
  To: pgsql-committers

Fix broken logic for reporting PL/Python function names in errcontext.

plpython_error_callback() reported the name of the function associated
with the topmost PL/Python execution context.  This was not merely
wrong if there were nested PL/Python contexts, but it risked a core
dump if the topmost one is an inline code block rather than a named
function.  That will have proname = NULL, and so we were passing a NULL
pointer to snprintf("%s").  It seems that none of the PL/Python-testing
machines in the buildfarm will dump core for that, but some platforms do,
as reported by Marina Polyakova.

Investigation finds that there actually is an existing regression test
that used to prove that the behavior was wrong, though apparently no one
had noticed that it was printing the wrong function name.  It stopped
showing the problem in 9.6 when we adjusted psql to not print CONTEXT
by default for NOTICE messages.  The problem is masked (if your platform
avoids the core dump) in error cases, because PL/Python will throw away
the originally generated error info in favor of a new traceback produced
at the outer level.

Repair by using ErrorContextCallback.arg to pass the correct context to
the error callback.  Add a regression test illustrating correct behavior.

Back-patch to all supported branches, since they're all broken this way.

Discussion: https://postgr.es/m/156b989dbc6fe7c4d3223cf51da61195@postgrespro.ru

Branch
------
REL9_3_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/457e9e88e357d60d2eed865ba7f52a274faf35f2

Modified Files
--------------
src/pl/plpython/expected/plpython_error.out        | 23 ++++++++++
src/pl/plpython/expected/plpython_error_0.out      | 23 ++++++++++
src/pl/plpython/expected/plpython_error_5.out      | 23 ++++++++++
.../plpython/expected/plpython_subtransaction.out  |  2 +-
src/pl/plpython/plpy_main.c                        | 52 +++++++++++-----------
src/pl/plpython/plpy_procedure.c                   |  4 +-
src/pl/plpython/sql/plpython_error.sql             | 16 +++++++
7 files changed, 113 insertions(+), 30 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2018-02-14 19:47 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-02-14 19:47 pgsql: Fix broken logic for reporting PL/Python function names in errco Tom Lane <tgl@sss.pgh.pa.us>
2018-02-14 19:47 pgsql: Fix broken logic for reporting PL/Python function names in errco Tom Lane <tgl@sss.pgh.pa.us>
2018-02-14 19:47 pgsql: Fix broken logic for reporting PL/Python function names in errco Tom Lane <tgl@sss.pgh.pa.us>
2018-02-14 19:47 pgsql: Fix broken logic for reporting PL/Python function names in errco Tom Lane <tgl@sss.pgh.pa.us>
2018-02-14 19:47 pgsql: Fix broken logic for reporting PL/Python function names in errco Tom Lane <tgl@sss.pgh.pa.us>
2018-02-14 19:47 pgsql: Fix broken logic for reporting PL/Python function names in errco 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