HomeClusterLabs Projects

Low: libcrmcommon: Avoid dumping core in pcmk__mem_assert()

Description

Low: libcrmcommon: Avoid dumping core in pcmk__mem_assert()

...as well as related functions pcmkassert_alloc_as() and
pcmk
str_copy_as(). The latter two would be macros that call
pcmk__mem_assert(), except that they need to return values, so they're
not macro-friendly.

They were never supposed to dump core, but the arguments to crm_abort()
are counterintuitive and we made a mistake.

Anything that calls abort() will dump core. crm_abort(..., FALSE, TRUE)
logs an assertion error message without calling abort() (and without
exiting). So we call crm_exit(CRM_EX_OSERR) afterward.

crm_abort(..., FALSE, TRUE) behaves similarly to CRM_LOG_ASSERT(). The
differences are that CRM_LOG_ASSERT() may dump core when tracing and
that CRM_LOG_ASSERT() stringifies the test expression instead of using
"Out of memory".

Also update affected unit tests. We no longer abort on allocation
failure, so the process doesn't get killed with SIGABRT, and
pcmk__assert_asserts() no longer passes.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>

Details

Provenance
nrwahl2Authored on Mar 20 2024, 1:28 AM
Parents
rP56ef671e6a38: Refactor: libcrmcommon: Move pcmk__mem_assert to results_internal.h
Branches
Unknown
Tags
Unknown