Page MenuHomeClusterLabs Projects

CRM_LOG_ASSERT() and CRM_CHECK() cause an abort if tracing
Open, LowPublic

Assigned To
Authored By
Mar 20 2024, 11:21 AM
  • Restricted Project
  • Restricted Project
Referenced Files


I haven't tested this yet, but by inspection

#  define CRM_LOG_ASSERT(expr) do {                 \
        if (!(expr)) {                                                  \
            static struct qb_log_callsite *core_cs = NULL;              \
            if(core_cs == NULL) {                                       \
                core_cs = qb_log_callsite_get(__func__, __FILE__,       \
                                              "log-assert", LOG_TRACE,  \
                                              __LINE__, 0);             \
            }                                                           \
            crm_abort(__FILE__, __func__, __LINE__, #expr,              \
                      core_cs?core_cs->targets:FALSE, TRUE);            \
        }                                                               \
    } while(0)

If we're tracing and any targets are enabled, we pass TRUE as the do_core argument of crm_abort(). Since do_fork=TRUE, fail_assert_as() gets called, which causes the current process to abort if it's *not* a daemon.

It's correct to dump core in this case for tracing purposes, but CRM_LOG_ASSERT() (and CRM_CHECK(), which is similar) should not cause the current process to abort.

Event Timeline

nrwahl2 created this task.
nrwahl2 created this object with edit policy "Restricted Project (Project)".

Ken mentioned in a meeting that this might be intended behavior because it doesn't really matter if a CLI tool aborts after an assertion.

That's basically true. However, I tend to think tracing shouldn't change a program's exit status.