pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Clear dangling pointer to avoid bogus EXPLAIN printout in a corn
6+ messages / 1 participants
[nested] [flat]

* pgsql: Clear dangling pointer to avoid bogus EXPLAIN printout in a corn
@ 2020-04-11 16:39  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2020-04-11 16:39 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Clear dangling pointer to avoid bogus EXPLAIN printout in a corner case.

ExecReScanHashJoin will destroy the join's hash table if it expects
that the inner relation will produce different rows on rescan.
Up to now it's not bothered to clear the additional pointer to that
hash table that exists in the child HashState node.  However, it's
possible for the query to terminate without building a fresh hash
table (this happens if the outer relation is found to be empty
during the final rescan).  So we can end with a dangling pointer
to a deleted hash table.  That was harmless originally, but since
9.0 EXPLAIN ANALYZE has used that pointer to print hash table
statistics.  In debug builds this reproducibly results in garbage
statistics.  In non-debug builds there's frequently no ill effects,
but in principle one could get wrong EXPLAIN ANALYZE output, or
perhaps even a crash if free() has released the hashtable memory
back to the OS.

To fix, just make sure we clear the additional pointer when destroying
the hash table.  In problematic cases, EXPLAIN ANALYZE will then print
no hashtable statistics (reverting to its pre-9.0 behavior).  This isn't
ideal, but since the problem manifests only in unusual corner cases,
it's hard to justify taking any risks to do better in the back
branches.  A follow-on patch will improve matters in HEAD.

Konstantin Knizhnik and Tom Lane, per diagnosis by Thomas Munro
of a trouble report from Alvaro Herrera.

Discussion: https://postgr.es/m/20200323165059.GA24950@alvherre.pgsql

Branch
------
REL_11_STABLE

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

Modified Files
--------------
src/backend/executor/nodeHashjoin.c | 6 ++++++
1 file changed, 6 insertions(+)



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

* pgsql: Clear dangling pointer to avoid bogus EXPLAIN printout in a corn
@ 2020-04-11 16:39  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2020-04-11 16:39 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Clear dangling pointer to avoid bogus EXPLAIN printout in a corner case.

ExecReScanHashJoin will destroy the join's hash table if it expects
that the inner relation will produce different rows on rescan.
Up to now it's not bothered to clear the additional pointer to that
hash table that exists in the child HashState node.  However, it's
possible for the query to terminate without building a fresh hash
table (this happens if the outer relation is found to be empty
during the final rescan).  So we can end with a dangling pointer
to a deleted hash table.  That was harmless originally, but since
9.0 EXPLAIN ANALYZE has used that pointer to print hash table
statistics.  In debug builds this reproducibly results in garbage
statistics.  In non-debug builds there's frequently no ill effects,
but in principle one could get wrong EXPLAIN ANALYZE output, or
perhaps even a crash if free() has released the hashtable memory
back to the OS.

To fix, just make sure we clear the additional pointer when destroying
the hash table.  In problematic cases, EXPLAIN ANALYZE will then print
no hashtable statistics (reverting to its pre-9.0 behavior).  This isn't
ideal, but since the problem manifests only in unusual corner cases,
it's hard to justify taking any risks to do better in the back
branches.  A follow-on patch will improve matters in HEAD.

Konstantin Knizhnik and Tom Lane, per diagnosis by Thomas Munro
of a trouble report from Alvaro Herrera.

Discussion: https://postgr.es/m/20200323165059.GA24950@alvherre.pgsql

Branch
------
REL9_5_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/30ce86367e3eeacfadfc748bf33194eb8fd3c1ba

Modified Files
--------------
src/backend/executor/nodeHashjoin.c | 6 ++++++
1 file changed, 6 insertions(+)



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

* pgsql: Clear dangling pointer to avoid bogus EXPLAIN printout in a corn
@ 2020-04-11 16:39  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2020-04-11 16:39 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Clear dangling pointer to avoid bogus EXPLAIN printout in a corner case.

ExecReScanHashJoin will destroy the join's hash table if it expects
that the inner relation will produce different rows on rescan.
Up to now it's not bothered to clear the additional pointer to that
hash table that exists in the child HashState node.  However, it's
possible for the query to terminate without building a fresh hash
table (this happens if the outer relation is found to be empty
during the final rescan).  So we can end with a dangling pointer
to a deleted hash table.  That was harmless originally, but since
9.0 EXPLAIN ANALYZE has used that pointer to print hash table
statistics.  In debug builds this reproducibly results in garbage
statistics.  In non-debug builds there's frequently no ill effects,
but in principle one could get wrong EXPLAIN ANALYZE output, or
perhaps even a crash if free() has released the hashtable memory
back to the OS.

To fix, just make sure we clear the additional pointer when destroying
the hash table.  In problematic cases, EXPLAIN ANALYZE will then print
no hashtable statistics (reverting to its pre-9.0 behavior).  This isn't
ideal, but since the problem manifests only in unusual corner cases,
it's hard to justify taking any risks to do better in the back
branches.  A follow-on patch will improve matters in HEAD.

Konstantin Knizhnik and Tom Lane, per diagnosis by Thomas Munro
of a trouble report from Alvaro Herrera.

Discussion: https://postgr.es/m/20200323165059.GA24950@alvherre.pgsql

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/8ffb86644530fb205cbecf85008d8e4a89d4a0a6

Modified Files
--------------
src/backend/executor/nodeHashjoin.c | 6 ++++++
1 file changed, 6 insertions(+)



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

* pgsql: Clear dangling pointer to avoid bogus EXPLAIN printout in a corn
@ 2020-04-11 16:39  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2020-04-11 16:39 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Clear dangling pointer to avoid bogus EXPLAIN printout in a corner case.

ExecReScanHashJoin will destroy the join's hash table if it expects
that the inner relation will produce different rows on rescan.
Up to now it's not bothered to clear the additional pointer to that
hash table that exists in the child HashState node.  However, it's
possible for the query to terminate without building a fresh hash
table (this happens if the outer relation is found to be empty
during the final rescan).  So we can end with a dangling pointer
to a deleted hash table.  That was harmless originally, but since
9.0 EXPLAIN ANALYZE has used that pointer to print hash table
statistics.  In debug builds this reproducibly results in garbage
statistics.  In non-debug builds there's frequently no ill effects,
but in principle one could get wrong EXPLAIN ANALYZE output, or
perhaps even a crash if free() has released the hashtable memory
back to the OS.

To fix, just make sure we clear the additional pointer when destroying
the hash table.  In problematic cases, EXPLAIN ANALYZE will then print
no hashtable statistics (reverting to its pre-9.0 behavior).  This isn't
ideal, but since the problem manifests only in unusual corner cases,
it's hard to justify taking any risks to do better in the back
branches.  A follow-on patch will improve matters in HEAD.

Konstantin Knizhnik and Tom Lane, per diagnosis by Thomas Munro
of a trouble report from Alvaro Herrera.

Discussion: https://postgr.es/m/20200323165059.GA24950@alvherre.pgsql

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5c27bce7f39ded1f027475221b732bbbc31a2bfe

Modified Files
--------------
src/backend/executor/nodeHashjoin.c | 6 ++++++
1 file changed, 6 insertions(+)



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

* pgsql: Clear dangling pointer to avoid bogus EXPLAIN printout in a corn
@ 2020-04-11 16:39  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2020-04-11 16:39 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Clear dangling pointer to avoid bogus EXPLAIN printout in a corner case.

ExecReScanHashJoin will destroy the join's hash table if it expects
that the inner relation will produce different rows on rescan.
Up to now it's not bothered to clear the additional pointer to that
hash table that exists in the child HashState node.  However, it's
possible for the query to terminate without building a fresh hash
table (this happens if the outer relation is found to be empty
during the final rescan).  So we can end with a dangling pointer
to a deleted hash table.  That was harmless originally, but since
9.0 EXPLAIN ANALYZE has used that pointer to print hash table
statistics.  In debug builds this reproducibly results in garbage
statistics.  In non-debug builds there's frequently no ill effects,
but in principle one could get wrong EXPLAIN ANALYZE output, or
perhaps even a crash if free() has released the hashtable memory
back to the OS.

To fix, just make sure we clear the additional pointer when destroying
the hash table.  In problematic cases, EXPLAIN ANALYZE will then print
no hashtable statistics (reverting to its pre-9.0 behavior).  This isn't
ideal, but since the problem manifests only in unusual corner cases,
it's hard to justify taking any risks to do better in the back
branches.  A follow-on patch will improve matters in HEAD.

Konstantin Knizhnik and Tom Lane, per diagnosis by Thomas Munro
of a trouble report from Alvaro Herrera.

Discussion: https://postgr.es/m/20200323165059.GA24950@alvherre.pgsql

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/1e6bb6125f33eeb2e6cc00e6af8777bdbe9a3786

Modified Files
--------------
src/backend/executor/nodeHashjoin.c | 6 ++++++
1 file changed, 6 insertions(+)



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

* pgsql: Clear dangling pointer to avoid bogus EXPLAIN printout in a corn
@ 2020-04-11 16:39  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2020-04-11 16:39 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Clear dangling pointer to avoid bogus EXPLAIN printout in a corner case.

ExecReScanHashJoin will destroy the join's hash table if it expects
that the inner relation will produce different rows on rescan.
Up to now it's not bothered to clear the additional pointer to that
hash table that exists in the child HashState node.  However, it's
possible for the query to terminate without building a fresh hash
table (this happens if the outer relation is found to be empty
during the final rescan).  So we can end with a dangling pointer
to a deleted hash table.  That was harmless originally, but since
9.0 EXPLAIN ANALYZE has used that pointer to print hash table
statistics.  In debug builds this reproducibly results in garbage
statistics.  In non-debug builds there's frequently no ill effects,
but in principle one could get wrong EXPLAIN ANALYZE output, or
perhaps even a crash if free() has released the hashtable memory
back to the OS.

To fix, just make sure we clear the additional pointer when destroying
the hash table.  In problematic cases, EXPLAIN ANALYZE will then print
no hashtable statistics (reverting to its pre-9.0 behavior).  This isn't
ideal, but since the problem manifests only in unusual corner cases,
it's hard to justify taking any risks to do better in the back
branches.  A follow-on patch will improve matters in HEAD.

Konstantin Knizhnik and Tom Lane, per diagnosis by Thomas Munro
of a trouble report from Alvaro Herrera.

Discussion: https://postgr.es/m/20200323165059.GA24950@alvherre.pgsql

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/242ca479fea1a217f91c0c2ce222abc4014e57fc

Modified Files
--------------
src/backend/executor/nodeHashjoin.c | 6 ++++++
1 file changed, 6 insertions(+)



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


end of thread, other threads:[~2020-04-11 16:39 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-04-11 16:39 pgsql: Clear dangling pointer to avoid bogus EXPLAIN printout in a corn Tom Lane <tgl@sss.pgh.pa.us>
2020-04-11 16:39 pgsql: Clear dangling pointer to avoid bogus EXPLAIN printout in a corn Tom Lane <tgl@sss.pgh.pa.us>
2020-04-11 16:39 pgsql: Clear dangling pointer to avoid bogus EXPLAIN printout in a corn Tom Lane <tgl@sss.pgh.pa.us>
2020-04-11 16:39 pgsql: Clear dangling pointer to avoid bogus EXPLAIN printout in a corn Tom Lane <tgl@sss.pgh.pa.us>
2020-04-11 16:39 pgsql: Clear dangling pointer to avoid bogus EXPLAIN printout in a corn Tom Lane <tgl@sss.pgh.pa.us>
2020-04-11 16:39 pgsql: Clear dangling pointer to avoid bogus EXPLAIN printout in a corn 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