From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28602 invoked by alias); 24 Aug 2009 18:54:36 -0000 Received: (qmail 28593 invoked by uid 22791); 24 Aug 2009 18:54:35 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 24 Aug 2009 18:54:27 +0000 Received: from int-mx07.intmail.prod.int.phx2.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n7OIsPll007624 for ; Mon, 24 Aug 2009 14:54:25 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx07.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n7OIsOX9029292; Mon, 24 Aug 2009 14:54:25 -0400 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n7OIsNiX013174; Mon, 24 Aug 2009 14:54:23 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id A0C08378204; Mon, 24 Aug 2009 12:54:22 -0600 (MDT) From: Tom Tromey To: gdb-patches@sourceware.org Subject: Patch: FYI: don't 'return' from TRY_CATCH Reply-To: tromey@redhat.com Date: Mon, 24 Aug 2009 19:03:00 -0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-08/txt/msg00391.txt.bz2 --=-=-= Content-length: 333 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 --=-=-= Content-Disposition: attachment Content-Description: try-catch.el Content-length: 1341 ;;; Look for malformed TRY_CATCH (defconst dir-to-scan (pop argv)) (defun scan-try-catch () (unless (file-directory-p dir-to-scan) (error "Usage: emacs --script try-catch.el DIR")) ;; Lame subdir list. (dolist (subdir '("." "cli" "mi" "python" "tui")) (dolist (file (directory-files (expand-file-name subdir dir-to-scan) t "[.][chy]$")) (save-excursion (find-file file) (goto-char (point-min)) ;; (message "Processing %s" file) ;; Skip #define TRY_CATCH .. (while (re-search-forward "^[^#].*\\_" nil 'move) (let ((here (point))) (skip-chars-forward " \t\n") (if (not (looking-at "(")) ;; Probably a comment -- skip it. nil (forward-sexp) (skip-chars-forward " \t\n") ;; It is hard to handle non-braced bodies in elisp. (if (not (looking-at "{")) (message "%s:%d: non-conforming TRY_CATCH" file (line-number-at-pos here)) (let ((end (save-excursion (forward-sexp) (point)))) ;; Note that there's no need to scan nested ;; TRY_CATCHes. (while (re-search-forward "\\_<\\(goto\\|return\\)\\_>" end 'move) (message "%s:%d: %s in TRY_CATCH" file (line-number-at-pos (point)) (match-string 1)))))))) (kill-buffer))))) (byte-compile 'scan-try-catch) (scan-try-catch) --=-=-= Content-length: 1044 2009-08-24 Tom Tromey * 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; --=-=-=--