git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: Carlo Arenas <carenas@gmail.com>,
	git@vger.kernel.org, phillip.wood@talktalk.net
Subject: Re: [PATCH 2/2] config.mak.dev: alternative workaround to gcc 12 warning in http.c
Date: Sat, 16 Apr 2022 07:23:24 -0700	[thread overview]
Message-ID: <xmqq1qxx6rab.fsf@gitster.g> (raw)
In-Reply-To: 220416.86lew5akh1.gmgdl@evledraar.gmail.com

Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:

> I.e. the assignment earlier in the function is unconditional, why
> wouldn't the clearing of the data correspond to that assignment and
> clear it unconditionally?

The original problem description that introduced .finished member
indicates that inside the while() loop, the same slot object can be
completed (by feeding it to finish_active_slot(), which would also
clears its in_use thus making it reusable) and then later be reused
(by using it for a different request).

The dispatching is done by calling step_active_slots() repeatedly
inside the loop and I do not think there is any multi-threaded
concurrency to worry about here.  The protection is against a case
where such a slot, which was originally ours and pointed at our
on-stack finished variable with its finished member, is reused for a
different request, and its finished member is used in a similar way
to point at the on-stack finish variable in somebody else's
stackframe in the future code.  If the slot instance we were using
as ours upon the entry of this function is being used for another
request already (the fix that required the .finished member is an
enough explanation that it is a real concern), after we leave the
loop, the slot instance is no longer ours, so we need to be careful
when we clear it.

At the entry of this function, the story is vastly different. The
slot instance belongs to us---the caller chose the slot and decided
to use it to service a particular request and threw the slot
instance at us, so there is nothing wrong to unconditionally use the
.finished member of the slot and point it at a variable in our
stackframe.  But after the loop leaves, and the slot may or may not
be already reused to hold another request.  If .finished is set and
it is the value that points at the variable in our stackframe, then
we are the only one who could have set that and it is safe to clear.
Any other value other than NULL, we do not know at that point who
set it, and it is being used for a request that we have nothing to
do with.  That is why we want to refrain from touching it when it is
not clearly ours.




  reply	other threads:[~2022-04-16 14:23 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-15 12:39 [PATCH] ci: lock "pedantic" job into fedora 35 and other cleanup Carlo Marcelo Arenas Belón
2022-04-15 13:17 ` Ævar Arnfjörð Bjarmason
2022-04-15 13:50 ` Phillip Wood
2022-04-15 18:31 ` Junio C Hamano
2022-04-15 21:03   ` Carlo Arenas
2022-04-15 22:20     ` Junio C Hamano
2022-04-15 23:13 ` [PATCH 0/2] ci: avoid failures for pedantic job with fedora 36 Carlo Marcelo Arenas Belón
2022-04-15 23:13   ` [PATCH 1/2] config.mak.dev: workaround gcc 12 bug affecting "pedantic" CI job Carlo Marcelo Arenas Belón
2022-04-15 23:41     ` Ævar Arnfjörð Bjarmason
2022-04-16  0:08       ` Carlo Arenas
2022-04-16  0:55         ` Ævar Arnfjörð Bjarmason
2022-04-16  5:56           ` Junio C Hamano
2022-04-16 12:33             ` Ævar Arnfjörð Bjarmason
2022-04-16  0:19       ` Junio C Hamano
2022-04-15 23:56     ` Junio C Hamano
2022-04-15 23:13   ` [PATCH 2/2] config.mak.dev: alternative workaround to gcc 12 warning in http.c Carlo Marcelo Arenas Belón
2022-04-15 23:34     ` Junio C Hamano
2022-04-16  0:02       ` Carlo Arenas
2022-04-16  0:28         ` Junio C Hamano
2022-04-16  0:51           ` Carlo Arenas
2022-04-16  1:00           ` Junio C Hamano
2022-04-16 12:50             ` Ævar Arnfjörð Bjarmason
2022-04-16  1:20           ` Ævar Arnfjörð Bjarmason
2022-04-16 14:23             ` Junio C Hamano [this message]
2022-04-16  1:08         ` Ævar Arnfjörð Bjarmason

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=xmqq1qxx6rab.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=carenas@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=phillip.wood@talktalk.net \
    /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).