git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git-svn: write memoized data explicitly to avoid Storable bug

From
Sergey Vlasov <vsu@altlinux.ru>
Date
Jul 18, 2010, 12:17 UTC
Message-ID
<1279455469-6384-1-git-send-email-vsu@altlinux.ru>

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
Next: Eric Wong
Message 1 of 5 in “git-svn: write memoized data explicitly to avoid Storable bug”
  1. git-svn: write memoized data explicitly to avoid Storable bugSergey Vlasov, Jul 18, 2010
  2. Eric WongJul 19, 2010
  3. Junio C HamanoJul 19, 2010
  4. Ævar Arnfjörð BjarmasonJul 20, 2010
  5. Eric WongJul 20, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.