|
|
Message-ID: <20201026032943.GK534@brightrain.aerifal.cx>
Date: Sun, 25 Oct 2020 23:29:43 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: 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 <semaphore.h>
> #include <sys/membarrier.h>
> #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; i<qpos; i++) queue[i]->mark = 0;
> + for (i=0; i<qpos; i++) if (queue[i]->ctor_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
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.