Gah. Calling malloc_create_zone
followed by malloc_zone_register of said zone is causing the problem. Omitting
the register seems to work fine and doesn’t cause the hang.
Is this legit? Are you not
supposed to register a zone after creation? The comments in malloc/malloc.h say
that malloc_zone_register “regisers a freshly created zone; should typically be
called after a zone has been created”. Or this function only for zones you’re
building from scratch (i.e., filling out the structs)?
From: Nathan Herring
Sent: Wednesday, September 17, 2008 3:46 PM
To: Nathan Herring; email@hidden
Subject: RE: spinlock under fork()?
The second zone under
MallocDebug is there if you just click update at the right time. (silly me). It
is still strange that MallocDebug hides the problem entirely.
From: Nathan Herring
Sent: Wednesday, September 17, 2008 3:25 PM
To: Nathan Herring; email@hidden
Subject: RE: spinlock under fork()?
We’ve narrowed this down a
little further. We introduced a change where we create a new malloc_zone and
put some of our allocations in that zone rather than the default zone. If we
just put all allocations in the default zone, this doesn’t recur. If we use
MallocDebug, it doesn’t recur (and furthermore it doesn’t appear to have a
second zone in that case!)
It
looks like the spinlock is under malloc_prepare_fork, and thus this is entirely
malloc-(zone) related. We have logging around all of our malloc calls to the
new zone, but clearly I cannot instrument all the others without having an
interposing library like libMallocDebug. Anything specific I should be looking
for?
Thx in advance,
nh
From:
darwin-dev-bounces+nathanh=email@hidden
[mailto:darwin-dev-bounces+nathanh=email@hidden] On Behalf
Of Nathan Herring
Sent: Monday, September 15, 2008 4:59 PM
To: email@hidden
Subject: spinlock under fork()?
We’re seeing a Safari hang when our plugin has been loaded
and run when you go to Preferences and then the Bookmark tab. Safari is loading
a nib, and underneath some Safari code there’s a call to “-[NSConcreteTask
launch]” followed by a call to fork() followed by spinlocking forever. What
spin lock does fork() use and does it share it with other system pieces? Are
there any hints as to figuring out what deadlocked?
--
Nathan Herring
com.microsoft.devdiv.clr.os/development