From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 19200 invoked from network); 26 Oct 2020 03:29:58 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 26 Oct 2020 03:29:58 -0000 Received: (qmail 22322 invoked by uid 550); 26 Oct 2020 03:29:56 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 22295 invoked from network); 26 Oct 2020 03:29:55 -0000 Date: Sun, 25 Oct 2020 23:29:43 -0400 From: Rich Felker To: musl@lists.openwall.com Message-ID: <20201026032943.GK534@brightrain.aerifal.cx> References: <20201026005028.GI534@brightrain.aerifal.cx> <20201026005912.GJ534@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201026005912.GJ534@brightrain.aerifal.cx> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] Status report and MT fork On Sun, Oct 25, 2020 at 08:59:20PM -0400, Rich Felker wrote: > diff --git a/ldso/dynlink.c b/ldso/dynlink.c > index af983692..32e88508 100644 > --- a/ldso/dynlink.c > +++ b/ldso/dynlink.c > @@ -21,6 +21,7 @@ > #include > #include > #include "pthread_impl.h" > +#include "fork_impl.h" > #include "libc.h" > #include "dynlink.h" > > @@ -1404,6 +1405,17 @@ void __libc_exit_fini() > } > } > > +void __ldso_atfork(int who) > +{ > + if (who<0) { > + pthread_rwlock_wrlock(&lock); > + pthread_mutex_lock(&init_fini_lock); > + } else { > + pthread_mutex_unlock(&init_fini_lock); > + pthread_rwlock_unlock(&lock); > + } > +} > + > static struct dso **queue_ctors(struct dso *dso) > { > size_t cnt, qpos, spos, i; > @@ -1462,6 +1474,12 @@ static struct dso **queue_ctors(struct dso *dso) > } > queue[qpos] = 0; > for (i=0; imark = 0; > + for (i=0; ictor_visitor->tid < 0) { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid access as-is, should be queue[i]->ctor_visitor && ... > + error("State of %s is inconsistent due to multithreaded fork\n", > + queue[i]->name); > + free(queue); > + if (runtime) longjmp(*rtld_fail, 1); > + } > > return queue; > } Rich