Memory leak in __wt_prepared_discover_filter_apply_handles

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • WT12.0.0, 9.0.0-rc0
    • Affects Version/s: None
    • Component/s: Timestamps
    • None
    • Storage Engines - Transactions
    • 449.745
    • SE Transactions - 2026-05-22, SE Transactions - 2026-06-05
    • 2

      ASAN testing discovered that __wt_prepared_discover_filter_apply_handles allocates a string (by way of __wt_meta_checkpoint_last_name) but does not free it. I tested a fix that seems to work correctly.

      diff --git a/src/third_party/wiredtiger/src/prepared_discover/prepared_discover_walk.c b/src/third_party/wiredtiger/src/prepared_discover/prepared_discover_walk.c
      index d8111dbd1e3..9fc4f530f6f 100644
      --- a/src/third_party/wiredtiger/src/prepared_discover/prepared_discover_walk.c
      +++ b/src/third_party/wiredtiger/src/prepared_discover/prepared_discover_walk.c
      @@ -463,6 +463,8 @@ __wt_prepared_discover_filter_apply_handles(WT_SESSION_IMPL *session)
           const char *checkpoint_name, *uri, *config;
           bool has_prepare;
      
      +    checkpoint_name = NULL;
      +
           WT_RET(__wt_metadata_cursor(session, &cursor));
      
           while ((ret = cursor->next(cursor)) == 0) {
      @@ -489,12 +491,14 @@ __wt_prepared_discover_filter_apply_handles(WT_SESSION_IMPL *session)
                    */
                   WT_ERR(__wt_buf_fmt(session, stable_uri_buf, "%s/%s", uri, checkpoint_name));
                   uri = stable_uri_buf->data;
      +            __wt_free(session, checkpoint_name);
               }
               WT_ERR(__prepared_discover_walk_one_tree(session, uri));
           }
           if (ret == WT_NOTFOUND)
               ret = 0;
       err:
      +    __wt_free(session, checkpoint_name);
           WT_TRET(__wt_metadata_cursor_release(session, &cursor));
           __wt_scr_free(session, &stable_uri_buf);
           return (ret);

            Assignee:
            Shoufu Du
            Reporter:
            Justin Seyster
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: