From: Carlo Arenas <carenas@gmail.com>
To: Victoria Dye via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, gitster@pobox.com, philipoakley@iee.email,
eschwartz@archlinux.org, Victoria Dye <vdye@github.com>
Subject: Re: [PATCH] async_die_is_recursing: fix use of pthread_getspecific for Fedora
Date: Wed, 3 Nov 2021 19:23:23 -0700 [thread overview]
Message-ID: <CAPUEspjw4zypiywCBRc=y9uC4G5CKTE35GLVf_wDY436oO0C5w@mail.gmail.com> (raw)
In-Reply-To: <pull.1072.git.1635990465854.gitgitgadget@gmail.com>
On Wed, Nov 3, 2021 at 6:48 PM Victoria Dye via GitGit
> The fix imitates a workaround added in SELinux [2] by using the pointer to
> `ret` as the second argument to `pthread_getspecific`.
the SELinux workaround uses a valid global pointer though; while this won't
> diff --git a/run-command.c b/run-command.c
> index 7ef5cc712a9..a82cf69e7d3 100644
> --- a/run-command.c
> +++ b/run-command.c
> @@ -1099,7 +1099,7 @@ static NORETURN void die_async(const char *err, va_list params)
> static int async_die_is_recursing(void)
> {
> void *ret = pthread_getspecific(async_die_counter);
> - pthread_setspecific(async_die_counter, (void *)1);
> + pthread_setspecific(async_die_counter, &ret); /* set to any non-NULL valid pointer */
I guess this would work, since the pointer is never dereferenced, but
the use of (void *)1 was hacky, and this warning seems like the right
time to make it less so.
Would a dynamically allocated pthread_local variable be a better
option, or even a static global, since we don't care about its value
so no need to worry about any races?
If neither, would MAP_FAILED also trigger the warning?
Carlo
next prev parent reply other threads:[~2021-11-04 2:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-04 1:47 [PATCH] async_die_is_recursing: fix use of pthread_getspecific for Fedora Victoria Dye via GitGitGadget
2021-11-04 2:23 ` Carlo Arenas [this message]
2021-11-04 2:37 ` Jeff King
2021-11-04 3:20 ` Carlo Arenas
2021-11-04 5:56 ` Jeff King
2021-11-04 4:01 ` [PATCH v2] async_die_is_recursing: work around GCC v11.x issue on Fedora Victoria Dye via GitGitGadget
2021-11-04 5:58 ` Jeff King
2021-11-04 6:35 ` Junio C Hamano
2021-11-04 9:42 ` Ævar Arnfjörð Bjarmason
2021-11-04 13:08 ` Derrick Stolee
2021-11-04 17:46 ` Junio C Hamano
2021-11-05 21:45 ` Junio C Hamano
2021-11-04 8:43 ` Johannes Schindelin
2021-11-04 9:46 ` Carlo Arenas
2021-11-04 16:33 ` Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAPUEspjw4zypiywCBRc=y9uC4G5CKTE35GLVf_wDY436oO0C5w@mail.gmail.com' \
--to=carenas@gmail.com \
--cc=eschwartz@archlinux.org \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
--cc=philipoakley@iee.email \
--cc=vdye@github.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).