pgbackrest.git / summary / log / commit / refs

commit    240cd755d19ae2688d0deee65c00daf0651bb601
Author:   David Steele <david@pgmasters.net>
Date:     Wed Sep 14 17:06:06 2022 +0000

    Add mem context test missing from 0f7b6a33.
    
    A coverage exception was added during development but was not removed before commit.
    
    Remove the exception and add a test for coverage.


doc/xml/release.xml | 5 ++++- src/common/memContext.c | 2 +- test/src/module/common/memContextTest.c | 25 +++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/doc/xml/release.xml b/doc/xml/release.xml index 437ac067a..ddc4d9d1f 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -100,7 +100,10 @@ <release-development-list> <release-item> - <github-pull-request id="1842"/> + <commit subject="Skip mem context cleanup in CATCH_FATAL() block."> + <github-pull-request id="1842"/> + </commit> + <commit subject="Add mem context test missing from 0f7b6a33."/> <release-item-contributor-list> <release-item-contributor id="david.steele"/> diff --git a/src/common/memContext.c b/src/common/memContext.c index ddac5ffee..a9244e3ed 100644 --- a/src/common/memContext.c +++ b/src/common/memContext.c @@ -1064,7 +1064,7 @@ memContextClean(const unsigned int tryDepth, const bool fatal) // mask the original error. if (memContextStack[memContextMaxStackIdx].type == memContextStackTypeNew) { - if (!fatal) // {uncovered !!!} + if (!fatal) memContextFree(memContextStack[memContextMaxStackIdx].memContext); } // Else find the prior context and make it the current context diff --git a/test/src/module/common/memContextTest.c b/test/src/module/common/memContextTest.c index 08f4981fb..ec0fb5918 100644 --- a/test/src/module/common/memContextTest.c +++ b/test/src/module/common/memContextTest.c @@ -426,6 +426,31 @@ testRun(void) TEST_RESULT_BOOL(catch, true, "new context error was caught"); TEST_RESULT_PTR(memContextCurrent(), memContextTop(), "context is now 'TOP'"); + + // ------------------------------------------------------------------------------------------------------------------------ + TEST_TITLE("new context not freed on fatal error"); + + MemContext *volatile memContextFatal; + catch = false; + + TRY_BEGIN() + { + MEM_CONTEXT_NEW_BEGIN(test-new-failed-fatal-block, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = MEM_CONTEXT_QTY_MAX) + { + memContextFatal = MEM_CONTEXT_NEW(); + THROW(AssertError, "create failed"); + } + MEM_CONTEXT_NEW_END(); + } + CATCH_FATAL() + { + catch = true; + } + TRY_END(); + + TEST_RESULT_VOID(memContextFree(memContextFatal), "free new context not freed by catch fatal"); + TEST_RESULT_BOOL(catch, true, "new context error was caught"); + TEST_RESULT_PTR(memContextCurrent(), memContextTop(), "context is now 'TOP'"); } // ***************************************************************************************************************************** [parent: 8fb61a809dc6]