This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: FYI: don't 'return' from TRY_CATCH


I'm checking this in.

It is not ok to 'return' from inside a TRY_CATCH.  This messes up the
cleanups and will lead to problems later.

I found this problem using the attached script.  It is simplistic but I
think it should catch most cases of this bug.  You can run it using:

    emacs --script try-catch.el /path/to/src/gdb

Tom

Attachment: txt00028.txt
Description: try-catch.el

2009-08-24  Tom Tromey  <tromey@redhat.com>

	* python/python-value.c (valpy_richcompare): Don't return from
	inside a TRY_CATCH.

Index: python/python-value.c
===================================================================
RCS file: /cvs/src/src/gdb/python/python-value.c,v
retrieving revision 1.26
diff -u -r1.26 python-value.c
--- python/python-value.c	14 Aug 2009 00:32:33 -0000	1.26
+++ python/python-value.c	24 Aug 2009 18:50:31 -0000
@@ -693,7 +693,10 @@
     {
       value_other = convert_value_from_python (other);
       if (value_other == NULL)
-	return NULL;
+	{
+	  result = -1;
+	  break;
+	}
 
       switch (op) {
         case Py_LT:
@@ -720,11 +723,16 @@
 	  /* Can't happen.  */
 	  PyErr_SetString (PyExc_NotImplementedError,
 			   "Invalid operation on gdb.Value.");
-	  return NULL;
+	  result = -1;
+	  break;
       }
     }
   GDB_PY_HANDLE_EXCEPTION (except);
 
+  /* In this case, the Python exception has already been set.  */
+  if (result < 0)
+    return NULL;
+
   if (result == 1)
     Py_RETURN_TRUE;
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]