Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: postgresql-cfbot/postgresql
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: cf/5635~1
Choose a base ref
...
head repository: postgresql-cfbot/postgresql
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cf/5635
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on May 28, 2025

  1. Fix memory leakage when function compilation fails.

    In pl_comp.c, initially create the plpgsql function's cache context
    under the assumed-short-lived caller's context, and reparent it under
    CacheMemoryContext only upon success.  This avoids a process-lifespan
    leak of 8kB or more if the function contains syntax errors.  (This
    leakage has existed for a long time without many complaints, but as
    we move towards a possibly multi-threaded future, getting rid of
    process-lifespan leaks grows more important.)
    
    In funccache.c, arrange to reclaim the CachedFunction struct in case
    the language-specific compile callback function throws an error;
    previously, that resulted in an independent process-lifespan leak.
    This is arguably a new bug in v18, since the leakage now occurred
    for SQL-language functions as well as plpgsql.
    
    Also, don't fill fn_xmin/fn_tid/dcallback until after successful
    completion of the compile callback.  This avoids a scenario where a
    partially-built function cache might appear already valid upon later
    inspection, and another scenario where dcallback might fail upon being
    presented with an incomplete cache entry.  We would have to reach such
    a faulty cache entry via a pre-existing fn_extra pointer, so I'm not
    sure these scenarios correspond to any live bug.  (The predecessor
    code in pl_comp.c never took any care about this, and we've heard no
    complaints about that.)  Still, it's better to be careful.
    
    Given the lack of field complaints, I'm not very excited about
    back-patching any of this; but it seems still in-scope for v18.
    
    Discussion: https://postgr.es/m/999171.1748300004@sss.pgh.pa.us
    tglsfdc committed May 28, 2025
    Configuration menu
    Copy the full SHA
    be86ca1 View commit details
    Browse the repository at this point in the history
Loading