Index: src/lib/sudoku_maker.py
===================================================================
--- src/lib/sudoku_maker.py	(revisjon 6207)
+++ src/lib/sudoku_maker.py	(arbeidskopi)
@@ -419,10 +419,18 @@
         if not os.path.exists(directory):
             os.makedirs(directory)
         ofi = file(self.pickle_to,'w')
-        pickle.dump({'by_solution':self.puzzles_by_solution,
-                     'names':self.names,
-                     'metaname':self.top_name},
-                     ofi)
+	try:
+	    sys.setcheckinterval(sys.maxint)
+	    # Statements in this block are assured to run atomically. 
+	    # The following statement has been known to create thread 
+	    # race conditions where several threads modify the object
+	    # being pickled, resulting in a crash.          - Andreas  
+            pickle.dump({'by_solution':self.puzzles_by_solution,
+                         'names':self.names,
+                         'metaname':self.top_name},
+                         ofi)
+	finally:
+	    sys.setcheckinterval(100)
         ofi.close()
 
     def list_difficulties (self):
Index: ChangeLog
===================================================================
--- ChangeLog	(revisjon 6207)
+++ ChangeLog	(arbeidskopi)
@@ -1,3 +1,9 @@
+2007-05-01  Andreas Røsdal  <andreasr@gnome.org>
+
+	* src/lib/sudoku_maker.py: Fix a race condition which occurs
+	when saving puzzles on exit. The solution is to run the pickle
+	operation atomically. This solves Bug #409172 et al.
+
 2007-04-22  Robert Ancell <robert.ancell@gmail.com>
 
 	* src/lib/gnome_sudoku.py Catch exceptions when launching help (Bug #418193)
