git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: "Martin Ågren" <martin.agren@gmail.com>
Cc: Eric Sunshine <sunshine@sunshineco.com>,
	Stefan Beller <sbeller@google.com>,
	Andrey Okoshkin <a.okoshkin@samsung.com>,
	"git@vger.kernel.org" <git@vger.kernel.org>,
	vmiklos@frugalware.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] merge-recursive: check GIT_MERGE_VERBOSITY only once
Date: Tue, 24 Oct 2017 12:52:21 -0700	[thread overview]
Message-ID: <20171024195221.gqgtibwjaztgeel6@sigill.intra.peff.net> (raw)
In-Reply-To: <CAN0heSp7b_6n3y=s4++oWhkPUuM=s9L7LWVx5vn8o=5aH6DKKw@mail.gmail.com>

On Tue, Oct 24, 2017 at 07:11:24PM +0200, Martin Ågren wrote:

> On 24 October 2017 at 18:45, Eric Sunshine <sunshine@sunshineco.com> wrote:
> > On Tue, Oct 24, 2017 at 12:28 PM, Stefan Beller <sbeller@google.com> wrote:
> >> On Tue, Oct 24, 2017 at 8:27 AM, Andrey Okoshkin <a.okoshkin@samsung.com> wrote:
> >>> Add check of 'GIT_MERGE_VERBOSITY' environment variable only once in
> >>> init_merge_options().
> >>> Consequential call of getenv() may return NULL pointer and strtol() crashes.
> >>> However the stored pointer to the obtained getenv() result may be invalidated
> >>> by some other getenv() call from another thread as getenv() is not thread-safe.
> 
> I'm having trouble wrapping my head around this. Under which
> circumstances could the second call in the current code return NULL, but
> the code after your patch behave in a well-defined (and correct) way?

Yeah, it's not at all clear to me this is solving a real problem. I know
Andrey mentioned playing around with fault injection in an earlier
thread, so I'm wondering if there is an artificial fault being injected
into the second getenv() call. Which does not seem like something that
should be possible in the real world.

I definitely agree with the sentiment that as few things as possible
should happen between calling getenv() and using its result. I've seen
real bugs there from unexpected invalidation of the static buffer.

-Peff

  reply	other threads:[~2017-10-24 19:52 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20171024152727epcas2p4fb7dcf147e44aadf7733098151d469a5@epcas2p4.samsung.com>
2017-10-24 15:27 ` [PATCH] merge-recursive: check GIT_MERGE_VERBOSITY only once Andrey Okoshkin
2017-10-24 16:28   ` Stefan Beller
2017-10-24 16:45     ` Eric Sunshine
2017-10-24 17:11       ` Martin Ågren
2017-10-24 19:52         ` Jeff King [this message]
2017-10-25  1:48           ` Junio C Hamano
2017-10-25  4:07             ` Eric Sunshine
2017-10-25  7:27               ` Jeff King
2017-10-25 11:39                 ` [PATCH v2] " Andrey Okoshkin
2017-10-25 11:53                   ` Eric Sunshine
2017-10-25 12:27                     ` Andrey Okoshkin
2017-10-25 13:03                     ` [PATCH v3] " Andrey Okoshkin
2017-10-27 17:29                       ` Stefan Beller
2017-10-30  7:42                         ` [PATCH v4] " Andrey Okoshkin
2017-10-31  1:42                           ` Junio C Hamano
2017-10-31  2:26                             ` Junio C Hamano
2017-10-31  7:13                               ` Andrey Okoshkin
2017-10-31  7:20                                 ` Junio C Hamano
2017-10-31  9:09                                   ` [PATCH v5] " Andrey Okoshkin
2017-10-25 11:13           ` [PATCH] " Andrey Okoshkin
2017-10-25 10:49       ` Andrey Okoshkin
2017-10-25 10:49     ` Andrey Okoshkin

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171024195221.gqgtibwjaztgeel6@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=a.okoshkin@samsung.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=martin.agren@gmail.com \
    --cc=sbeller@google.com \
    --cc=sunshine@sunshineco.com \
    --cc=vmiklos@frugalware.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).