]> granicus.if.org Git - postgresql/commit
Make plperl safe against functions that are redefined while running.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 10 Sep 2012 00:33:14 +0000 (20:33 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 10 Sep 2012 00:33:14 +0000 (20:33 -0400)
commit4da51c25a505b09b2e312953da97502111a8c69e
treef146485ecab047ac4b08d54ef4e1d01ceb74a41a
parent63ea46f5db90709032d98819c744881253d933f7
Make plperl safe against functions that are redefined while running.

validate_plperl_function() supposed that it could free an old
plperl_proc_desc struct immediately upon detecting that it was stale.
However, if a plperl function is called recursively, this could result
in deleting the struct out from under an outer invocation, leading to
misbehavior or crashes.  Add a simple reference-count mechanism to
ensure that such structs are freed only when the last reference goes
away.

Per investigation of bug #7516 from Marko Tiikkaja.  I am not certain
that this error explains his report, because he says he didn't have
any recursive calls --- but it's hard to see how else it could have
crashed right there.  In any case, this definitely fixes some problems
in the area.

Back-patch to all active branches.
src/pl/plperl/expected/plperl.out
src/pl/plperl/plperl.c
src/pl/plperl/sql/plperl.sql