Re: FYI: ^T use during poudriere bulk vs. /bin/sh operation: I got a "Unsafe ckmalloc() call" Abort trap that left a mess

From: Jilles Tjoelker <jilles_at_stack.nl>
Date: Tue, 05 Sep 2023 14:07:39 UTC
On Mon, Sep 04, 2023 at 05:16:56PM -0700, Mark Millard wrote:
> During a (zfs based) poudriere bulk -a run a ^T got a:

> Unsafe ckmalloc() call
> Abort trap (core dumped)

> My attribution to ^T handling is unverified: I did not find the
> sh.core file. It is just what the timing looked like.

The error message means that ckmalloc() is being called without INTOFF
in effect, i.e. at the time a SIGINT may cause an EXINT exception
(longjmp()). Although malloc(3)'s data structures could be protected by
surrounding the malloc() call with INTOFF and INTON, this would lead to
a memory leak if a SIGINT happened at that time, since the pointer to
the allocated memory would be lost. This check was added in git commit
9f9c9549fd4f7ce362e95e3a8a50f00ffd00175c.

My first guess would be that there is a bug with a rare edge case of
traps and/or errors, such as not applying INTOFF again after an
exception has turned it off or doing INTON when interrupts are already
enabled. A less likely possibility could be a violation related to
volatile and synchronization between a signal handler and the main flow.

Many common code paths are all exercised by the tests and normal use, so
it must be something special in some way.

-- 
Jilles Tjoelker