Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 6 Oct 2022 14:21:51 -0400
From: Rich Felker <>
Subject: Re: MT fork and key_lock in pthread_key_create.c

On Thu, Oct 06, 2022 at 09:37:50AM +0300, Alexey Izbyshev wrote:
> Hi,
> I noticed that fork() doesn't take key_lock that is used to protect
> the global table of thread-specific keys. I couldn't find mentions
> of this lock in the MT fork discussion in the mailing list archive.
> Was this lock overlooked?

I think what happened was that we made the main list of locks to
review and take care of via grep for LOCK, and then manually added
known instances of locks using other locking primitives. This one must
have been missed.

Having special-case lock types like this is kinda a pain, but as long
as there aren't too many I guess it's not a big deal.

> Also, I looked at how __aio_atfork() handles a similar case with
> maplock, and it seems wrong. It takes the read lock and then simply
> unlocks it both in the parent and in the child. But if there were
> other holders of the read lock at the time of fork(), the lock won't
> end up in the unlocked state in the child. It should probably be
> completely nulled-out in the child instead.

Conceptually, perhaps it should be taking the write-lock instead?
But null-out is probably okay too, and less costly.


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.