From 95ae32458037654de9363cbba07093f9756d7ae0 Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Sat, 23 Jan 2021 23:46:55 +0300 Subject: [PATCH] mdbx: fix reclaimed-list allocation during nested txn start. Change-Id: Ia70e01ed69a001249ce14b4930452a469d04b824 --- src/core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core.c b/src/core.c index 62ee6931..e4d47df5 100644 --- a/src/core.c +++ b/src/core.c @@ -6943,8 +6943,10 @@ int mdbx_txn_begin_ex(MDBX_env *env, MDBX_txn *parent, MDBX_txn_flags_t flags, txn->mt_dbiseqs = parent->mt_dbiseqs; rc = mdbx_dpl_alloc(txn); if (likely(rc == MDBX_SUCCESS)) { + const unsigned len = + MDBX_PNL_SIZE(parent->tw.reclaimed_pglist) + parent->tw.loose_count; txn->tw.reclaimed_pglist = - mdbx_pnl_alloc(MDBX_PNL_ALLOCLEN(parent->tw.reclaimed_pglist)); + mdbx_pnl_alloc((len > MDBX_PNL_INITIAL) ? len : MDBX_PNL_INITIAL); if (unlikely(!txn->tw.reclaimed_pglist)) rc = MDBX_ENOMEM; } @@ -6983,6 +6985,8 @@ int mdbx_txn_begin_ex(MDBX_env *env, MDBX_txn *parent, MDBX_txn_flags_t flags, if (parent->tw.spill_pages) mdbx_spill_purge(parent); + mdbx_tassert(txn, MDBX_PNL_ALLOCLEN(txn->tw.reclaimed_pglist) >= + MDBX_PNL_SIZE(parent->tw.reclaimed_pglist)); memcpy(txn->tw.reclaimed_pglist, parent->tw.reclaimed_pglist, MDBX_PNL_SIZEOF(parent->tw.reclaimed_pglist)); mdbx_assert(env, mdbx_pnl_check4assert(