tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: How signal-safe is our malloc()?



On Fri, Nov 14, 2025 at 01:55:08PM -0500, Mouse wrote:
 > At work, we have a program that (because of its DOS heritage) does a
 > lot of work in signal handlers.
 > 
 > When I first ported it from DOS to NetBSD, I converted interrupt
 > handlers into signal handlers.  Then it crashed occasionally.  

If you didn't convert the cli/sti operations to sigprocmask, it's no
wonder. If you did, it must have already been broken :-)

That said:

 > This then makes me wonder why we didn't see the same on NetBSD.
 > signal(7) says our malloc isn't signal-safe either, but I'm wondering
 > whether it actually is signal-safe in 9.1 and signal safety just isn't
 > promised, or perhaps it's not signal-safe but the window of risk is
 > much smaller, or...what?

That's a good question. That said, the risk of an actual segfault
depends heavily on random differences in the order that things are
updated, and most likely it's just luck...

-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index