From: David Turner <dturner@twopensource.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git mailing list <git@vger.kernel.org>
Subject: Re: Freeing struct lock_file?
Date: Fri, 03 Apr 2015 20:24:43 -0400 [thread overview]
Message-ID: <1428107083.31333.11.camel@ubuntu> (raw)
In-Reply-To: <xmqqfv8gg9bp.fsf@gitster.dls.corp.google.com>
On Fri, 2015-04-03 at 15:01 -0700, Junio C Hamano wrote:
> David Turner <dturner@twopensource.com> writes:
>
> > Why is it impossible to free struct lock_files? I understand that they
> > become part of a linked list, and that there's an atexit handler that
> > goes over that list. But couldn't we just remove them from the linked
> > list and then free them?
>
> I suspect that the code is worried about getting a signal, while it
> is manipulating the linked list, and then cause the atexit handler
> to walk a list that is in a broken state.
This is technically possible, but practically unlikely: aligned
pointer-sized writes are atomic on very nearly every processor, and that
is all that is required to remove an item from a linked list safely in
this case (though not, of course, in the general multi-threaded case).
But I can see why git wouldn't want to depend on that behavior. C11 has
a way to do this safely, but AIUI, git doesn't want to move to C99 let
alone C11. So I guess this will just have to remain the way it is.
next prev parent reply other threads:[~2015-04-04 0:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-03 21:45 Freeing struct lock_file? David Turner
2015-04-03 22:01 ` Junio C Hamano
2015-04-04 0:24 ` David Turner [this message]
2015-04-04 7:16 ` Torsten Bögershausen
2015-04-06 18:02 ` David Turner
2015-04-04 19:04 ` C99 (Was: Re: Freeing struct lock_file?) brian m. carlson
2015-04-04 20:06 ` C99 Junio C Hamano
2015-04-04 20:36 ` C99 brian m. carlson
2015-04-07 1:12 ` Freeing struct lock_file? David Turner
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=1428107083.31333.11.camel@ubuntu \
--to=dturner@twopensource.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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).