HomeFreeBSD

libspl/assert: add lock around assertion output

Description

libspl/assert: add lock around assertion output

If multiple threads trip an assertion at the same moment (quite common),
they can be printing at the same time, and their output gets messy.

This adds a simple lock around the whole thing, to prevent a second task
printing assert output before the first has finished.

Additionally, if libspl_assert_ok is not set, abort() is called without
dropping the lock, so that any other asserting tasks will be killed
before starting any output, rather than only getting part-way through.
This is a tradeoff; it's assumed that multiple threads asserting at the
same moment are likely the same fault in different instances of a
thread, and so there won't be any more useful information from the other
tasks anyway.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <robn@despairlabs.com>
Sponsored-by: https://despairlabs.com/sponsor/
Closes #16140

Details

Provenance
rob.norris_klarasystems.comAuthored on Apr 28 2024, 2:49 AM
Tony Hutter <hutter2@llnl.gov>Committed on Jul 17 2024, 9:54 PM
Parents
rG96cad4ca4c1f: libspl/assert: show process/task details in assert output
Branches
Unknown
Tags
Unknown