stack_trace allows you to specify a custom allocator, which would protect against a lock held in the allocator (never ran into this in the real world though).
You're right about mutex & cv in the general case though
That assumes the specified allocator actually controls all allocations - somewhat doubtful across all platforms as things like dl_iterate_phdr() IIRC allocate memory (and take locks). And there's a lot more to writing signal safe code than not calling malloc. Unless an interface documents to be signal safe you're take better of assuming it is not.
FWIW I've run into malloc self dreadlocks due to rare signals plenty of time :(. In production workloads.
FWIW I've run into malloc self dreadlocks due to rare signals plenty of time :(. In production workloads.