Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20240120213232.GY4163@brightrain.aerifal.cx>
Date: Sat, 20 Jan 2024 16:32:32 -0500
From: Rich Felker <dalias@...c.org>
To: Markus Wichmann <nullplan@....net>
Cc: musl@...ts.openwall.com
Subject: Re: [PATCH] Split fork and abort locks

On Sat, Jan 20, 2024 at 09:12:28AM +0100, Markus Wichmann wrote:
> Hi all,
> 
> a while ago I had noticed that __abort_lock was being taken in some
> functions that have nothing to do with SIGABRT. Namely in the forking
> functions. Investigating this a bit, I noticed that __abort_lock had
> become dual purpose. But this is a code smell.
> 
> Actually, there are several locks that have expanded in scope a bit
> since their introduction. At least the ptc lock (__inhibit_ptc() et al.)
> deserves a closer look later on as well. Seems to me like in case of the
> default stack size, that lock is used simply because an rwlock was
> needed and this one was around.

The scope of this lock has always been modification to state that new
thread creation depends on, which is largely "how much storage does a
new thread need?"

Originally, the relevant state was just the amount of TLS memory
needed. With the addition of default stack size control, that also
became part of the relevant state. In theory these could be protected
by different locks, but I don't see any good reason for splitting
them.

The reason fork takes the __inhibit_ptc lock is that it has to take
all the internal locks; this has nothing to do with the scope of
what's protected by the particular lock.

Rich

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.