git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergey Vlasov <vsu@altlinux.ru>
To: git@vger.kernel.org
Cc: Eric Wong <normalperson@yhbt.net>,
	A Large Angry SCM <gitzilla@gmail.com>,
	Sergey Vlasov <vsu@altlinux.ru>
Subject: [PATCH] git-svn: write memoized data explicitly to avoid Storable bug
Date: Sun, 18 Jul 2010 16:17:49 +0400	[thread overview]
Message-ID: <1279455469-6384-1-git-send-email-vsu@altlinux.ru> (raw)

Apparently using the Storable module during global destruction is
unsafe - there is a bug which can cause segmentation faults:

  http://rt.cpan.org/Public/Bug/Display.html?id=36087
  http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=482355

The persistent memoization support introduced in commit 8bff7c538
relied on global destruction to write cached data, which was leading
to segfaults in some Perl configurations.  Calling Memoize::unmemoize
in the END block forces the cache writeout to be performed earlier,
thus avoiding the bug.

Signed-off-by: Sergey Vlasov <vsu@altlinux.ru>
---
 git-svn.perl |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

 In my case segfaults happen only when the perl-IO-Compress module is
 installed - apparently the attempt to load Compress::Zlib (now
 provided by IO::Compress) changes something.

 This unaswered report is also suspicious:

   http://thread.gmane.org/gmane.comp.version-control.git/142161

 (when running ./t9151-svn-mergeinfo.sh -v, the segfault should be
 visible: "error: git-svn died of signal 11").

diff --git a/git-svn.perl b/git-svn.perl
index 19d6848..c416358 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -3169,6 +3169,22 @@ sub has_no_changes {
 			LIST_CACHE => 'FAULT',
 		;
 	}
+
+	sub unmemoize_svn_mergeinfo_functions {
+		return if not $memoized;
+		$memoized = 0;
+
+		Memoize::unmemoize 'lookup_svn_merge';
+		Memoize::unmemoize 'check_cherry_pick';
+		Memoize::unmemoize 'has_no_changes';
+	}
+}
+
+END {
+	# Force cache writeout explicitly instead of waiting for
+	# global destruction to avoid segfault in Storable:
+	# http://rt.cpan.org/Public/Bug/Display.html?id=36087
+	unmemoize_svn_mergeinfo_functions();
 }
 
 sub parents_exclude {
-- 
1.6.0.2.321.g8406

             reply	other threads:[~2010-07-18 12:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-18 12:17 Sergey Vlasov [this message]
2010-07-19  6:39 ` [PATCH] git-svn: write memoized data explicitly to avoid Storable bug Eric Wong
2010-07-19 16:37   ` Junio C Hamano
2010-07-20 17:32 ` Ævar Arnfjörð Bjarmason
2010-07-20 19:02   ` Eric Wong

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=1279455469-6384-1-git-send-email-vsu@altlinux.ru \
    --to=vsu@altlinux.ru \
    --cc=git@vger.kernel.org \
    --cc=gitzilla@gmail.com \
    --cc=normalperson@yhbt.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).