package devtodo
tag 30722 patch
thanks

Okay, this is an easy fix, and is obvious once you see it, but it was tricky 
to track down. Basically, it's a classic case of an object being referenced 
AFTER it is deleted. Of course it works sometimes, on some architectures, 
but doesn't work in general.

--- TodoDB.cc.orig      2005-05-06 18:54:53.311120870 -0600
+++ TodoDB.cc   2005-05-06 18:53:18.838482894 -0600
@@ -749,8 +749,8 @@
                        erased++;
                        if (options.verbose > 1)
                                cout << info << "todo: permanently removing 
item '" << (*j) << "'" << normal << endl;
-                       erase(todo, *j);
                        t->db->setDirty(true);
+                       erase(todo, *j);
                } else
                        notfound.push_back(*j);
        }


Watching t->db in the debugged, you can see the pointer change after 
erase(todo, *j) is called. My guess is this doesn't happen (out of luck, 
probably) on i386, but it does on amd64.

Anyway, the fix is just to set the db dirty flag BEFORE deleting the todo 
that holds the pointer to it. Piece of cake. =)

(We should probably send this patch upstream as it is not an amd64 specific 
fix, and could break other architectures as well.)

-- 
Wesley J. Landaker <[EMAIL PROTECTED]>
OpenPGP FP: 4135 2A3B 4726 ACC5 9094  0097 F0A9 8A4C 4CD6 E3D2
--- TodoDB.cc.orig	2005-05-06 18:54:53.311120870 -0600
+++ TodoDB.cc	2005-05-06 18:53:18.838482894 -0600
@@ -749,8 +749,8 @@
 			erased++;
 			if (options.verbose > 1)
 				cout << info << "todo: permanently removing item '" << (*j) << "'" << normal << endl;
-			erase(todo, *j);
 			t->db->setDirty(true);
+			erase(todo, *j);
 		} else
 			notfound.push_back(*j);
 	}

Attachment: pgplVfoT3PqsG.pgp
Description: PGP signature

Reply via email to