From 0f82db941b9a9dddf6837a8bf4a086add29ea71b Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Thu, 4 Oct 2018 16:00:27 +0300 Subject: [PATCH] mdbx: add error-logging to mdbx_page_get(). Change-Id: I6a1a95ec6fc73aa7bf28875a89b1dd6c02ef5164 --- src/mdbx.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/mdbx.c b/src/mdbx.c index 1b2378ac..883b7a31 100644 --- a/src/mdbx.c +++ b/src/mdbx.c @@ -6927,13 +6927,20 @@ mapped: p = pgno2page(env, pgno); done: - if (unlikely(p->mp_pgno != pgno)) + if (unlikely(p->mp_pgno != pgno)) { + mdbx_error("mismatch pgno %" PRIaPGNO " (actual) != %" PRIaPGNO + " (expected)", + p->mp_pgno, pgno); return MDBX_CORRUPTED; + } if (unlikely(p->mp_upper < p->mp_lower || PAGEHDRSZ + p->mp_upper > env->me_psize) && - !IS_OVERFLOW(p)) + !IS_OVERFLOW(p)) { + mdbx_error("invalid page lower(%u)/upper(%u), pg-limit %u", p->mp_lower, + p->mp_upper, env->me_psize - PAGEHDRSZ); return MDBX_CORRUPTED; + } /* TODO: more checks here, including p->mp_validator */ *ret = p;