Thread

  1. Re: Accessing an invalid pointer in BufferManagerRelation structure

    Daniil Davydov <3danissimo@gmail.com> — 2025-10-20T19:03:35Z

    Hi,
    
    On Sun, Oct 19, 2025 at 6:32 PM Álvaro Herrera <alvherre@kurilemu.de> wrote:
    >
    > I edited your comments a bit.  What do you think of this version?
    >
    
    Thanks for looking into this! All added changes LGTM.
    
    > I don't think this is backpatchable material, mainly because you said
    > you don't see any situations in which relcache invalidations would
    > occur in the middle of this.  Can you can cause a problem to occur by
    > adding an untimely invalidation somewhere without this patch, which is
    > fixed by this patch?
    
    Yep, by now (if I did not miss anything) described problem cannot occur even
    with debug_discard_caches parameter on. But one of our clients had faced
    this problem, because we have some differences in source code. In the first
    letter I described scenario, when the occurrence of a problem becomes possible :
    ***
    if (just for example) we add acquiring of new lock into ExtendBufferedRelLocal
    or ExtendBufferedRelShared, relation cache will be invalidated (inside
    AcceptInvalidationMessages).
    ***
    
    >
    > BTW how does this interact with SMgrRelation pinning?
    
    Hm, maybe I don't fully understand the question. Smgr pinning is one of the side
    effects of BMR_GET_SMGR (in case we use this macro with
    invalidated/uninitialized
    rd_smgr entry).
    Without patch pincount cannot save us from undesirable invalidation,
    because it guards
    from smgr_destroy, not from smgr_release.
    
    --
    Best regards,
    Daniil Davydov