You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DISCARD PACKAGE can crash cached PL/iSQL callers #1452
A standalone PL/iSQL function that calls a package function can retain an FmgrInfo.fn_extra entry across DISCARD PACKAGE. Package cleanup frees the compiled dependent function but leaves its cached tuple identity valid, so the next invocation can treat the emptied function structure as reusable. The result is a backend segmentation fault.
Cached package FuncExpr.parent_func pointers and rebuilt function dependency lists can also outlive the package memory context or retain stale links after a reset.
This was found while separating correctness work from the package cleanup performance change in #1426. It was discovered by source inspection and a local regression reproducer, not from a reported production incident.
Reproduction
Create a package function.
Create and invoke a standalone PL/iSQL function that calls it.
Prepare and execute a direct package call.
Run DISCARD PACKAGE.
Invoke the standalone function again.
On the current base revision, step 5 terminates the backend with SIGSEGV.
Expected outcome
invalidate the cached dependent-function tuple identity before freeing its compiled tree
refresh package function expressions against the current package cache entry before dereferencing parent_func
clear removed dependency lists so rebuilt functions do not retain stale links
add a regression test covering cached callers, prepared plans, and repeated DISCARD PACKAGE
demonstrate that the regression fails on the base revision and passes with the fix
Activity
hanjianqiao commentedon Sep 2, 2026
ok