diff --git a/src/lib/core/fiber.c b/src/lib/core/fiber.c index ee478f336f18dbdacf131ce7c63dc271876c65d0..f6ff1aaa7bb8eadc98417200d43a8adb492227e5 100644 --- a/src/lib/core/fiber.c +++ b/src/lib/core/fiber.c @@ -1309,6 +1309,14 @@ fiber_stack_destroy(struct fiber *fiber, struct slab_cache *slabc) */ say_syserror("fiber: Can't put guard page to slab. " "Leak %zu bytes", (size_t)fiber->stack_size); + /* + * Suppress memory leak report for this object. + * + * Works even though it is not a beginning of + * allocation (there is ASAN slab cache allocation + * header). + */ + LSAN_IGNORE_OBJECT(fiber->stack_slab); } else { slab_put(slabc, fiber->stack_slab); } diff --git a/src/trivia/util.h b/src/trivia/util.h index bf4f04e60bc36f757ec275cf93641498feac6a3b..2bf13c181ba8534c8069e0f2cf0062cbd2022da8 100644 --- a/src/trivia/util.h +++ b/src/trivia/util.h @@ -827,6 +827,13 @@ illegal_instruction(void) } #endif +#ifdef ENABLE_ASAN +# include <sanitizer/lsan_interface.h> +# define LSAN_IGNORE_OBJECT(ptr) __lsan_ignore_object(ptr) +#else +# define LSAN_IGNORE_OBJECT(ptr) ((void)ptr) +#endif + #if defined(__cplusplus) } /* extern "C" */ #endif /* defined(__cplusplus) */ diff --git a/test/unit/fiber_stack.c b/test/unit/fiber_stack.c index 462540762c49f1244ae7e9d6fa1aced4c8fb2bd3..9cd9b5319920ccbf7c1050e3654bd5d1c386ba02 100644 --- a/test/unit/fiber_stack.c +++ b/test/unit/fiber_stack.c @@ -44,10 +44,6 @@ main_f(va_list ap) * gh-9026. Stack size crafted to be close to 64k so we should * hit red zone around stack when writing watermark if bug is not * fixed. - * - * The test is placed at the beginning because stderr is redirected - * to /dev/null at the end of the test and ASAN diagnostic will - * not be visible if the test will be placed at the end. */ fiber_attr = fiber_attr_new(); fiber_attr_setstacksize(fiber_attr, (64 << 10) - 128); @@ -130,17 +126,9 @@ main_f(va_list ap) inj = errinj(ERRINJ_FIBER_MPROTECT, ERRINJ_INT); inj->iparam = PROT_READ | PROT_WRITE; - /* On fiber_mprotect() fail we are logging number of bytes to be - * leaked. However, it depends on system page_size (_SC_PAGESIZE). - * On different OS's this parameter may vary. So let's temporary - * redirect stderr to dev/null to make this test stable regardless - * of OS. - */ - freopen("/dev/null", "w", stderr); fiber_start(fiber); fiber_join(fiber); inj->iparam = -1; - freopen("/dev/stderr", "w", stderr); used_after = slabc->allocated.stats.used; ok(used_after > used_before, "expected leak detected");