From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#23949: 25.0.95; Regression in handling error caused by (string-match-p "." nil) Date: Wed, 13 Jul 2016 17:24:49 +0300 Message-ID: <83mvllaa4u.fsf@gnu.org> References: <83lh17ati6.fsf@gnu.org> <83h9bvarb6.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1468419990 12499 80.91.229.3 (13 Jul 2016 14:26:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 13 Jul 2016 14:26:30 +0000 (UTC) Cc: schwab@suse.de, 23949@debbugs.gnu.org, kaushal.modi@gmail.com To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jul 13 16:26:18 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bNL7C-0007JU-AT for geb-bug-gnu-emacs@m.gmane.org; Wed, 13 Jul 2016 16:26:18 +0200 Original-Received: from localhost ([::1]:48025 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNL7B-000723-EH for geb-bug-gnu-emacs@m.gmane.org; Wed, 13 Jul 2016 10:26:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44054) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNL70-00070C-KG for bug-gnu-emacs@gnu.org; Wed, 13 Jul 2016 10:26:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bNL6w-0001aJ-Ez for bug-gnu-emacs@gnu.org; Wed, 13 Jul 2016 10:26:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37583) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNL6w-0001aD-Az for bug-gnu-emacs@gnu.org; Wed, 13 Jul 2016 10:26:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bNL6w-0002yU-7m for bug-gnu-emacs@gnu.org; Wed, 13 Jul 2016 10:26:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 Jul 2016 14:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23949 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23949-submit@debbugs.gnu.org id=B23949.146841992511373 (code B ref 23949); Wed, 13 Jul 2016 14:26:02 +0000 Original-Received: (at 23949) by debbugs.gnu.org; 13 Jul 2016 14:25:25 +0000 Original-Received: from localhost ([127.0.0.1]:49920 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bNL6H-0002xK-JT for submit@debbugs.gnu.org; Wed, 13 Jul 2016 10:25:25 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:52799) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bNL6B-0002wz-TH for 23949@debbugs.gnu.org; Wed, 13 Jul 2016 10:25:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bNL62-0001Pd-I1 for 23949@debbugs.gnu.org; Wed, 13 Jul 2016 10:25:10 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:55167) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNL62-0001Nd-Fu; Wed, 13 Jul 2016 10:25:06 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3826 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bNL60-0002iu-GB; Wed, 13 Jul 2016 10:25:04 -0400 In-reply-to: (message from Stefan Monnier on Tue, 12 Jul 2016 16:27:03 -0400) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:120992 Archived-At: > From: Stefan Monnier > Cc: Eli Zaretskii , schwab@suse.de, 23949@debbugs.gnu.org > Date: Tue, 12 Jul 2016 16:27:03 -0400 > > Clearly, the problem is that string-match-p uses > "(let ((inhibit-changing-match-data t))", Since this is the only difference between string-match and string-match-p, yes, that's pretty much obvious. But saying that doesn't yet point out the code which is affected by this binding in a way that breaks popping the debugger. > so the debugger is run with inhibit-changing-match-data bound to t > and that breaks lots of Elisp code. Then perhaps the solution is to avoid the effect of binding inhibit-changing-match-data on the debugger. > That's a general problem with the use dynamic binding to pass extra > parameters: you end up passing them not just to that one function but > also to all other functions called from that one. This is a strange thing to hear, from you of all the people. Dynamically binding variables around some expression is standard Emacs Lisp programming technique, used all over the place. The doc string of this particular variable even says so. How come it is suddenly a problem? I also think that the "breaks a lot of Elisp code" part is at least a tad exaggerated. We bind this particular variable in 2 functions that are called from more than 300 different places in the Emacs sources, so if doing so indeed breaks a lot of Lisp, we are in deep trouble, which I don't think is the case. Anyway, a cursory glance at help-function-arglist points to the problematic code. Compare this: (help-split-fundoc (documentation 'delete-file) nil) => ("(nil FILENAME &optional TRASH)" . "Delete file named FILENAME. If it is a symlink, remove the symlink. If file has multiple names, it continues to exist with the other names. TRASH non-nil means to trash the file instead of deleting, provided ‘delete-by-moving-to-trash’ is non-nil. When called interactively, TRASH is t if no prefix argument is given. With a prefix argument, TRASH is nil.") with this: (let ((inhibit-changing-match-data t)) (help-split-fundoc (documentation 'delete-file) nil)) => ("(nilnil" . "Delete fi") The latter is clearly bogus. Now, help-function-arglist calls help-split-fundoc, and then reads from the string produced by the latter: (let* ((doc (condition-case nil (documentation def) (error nil))) (docargs (if doc (car (help-split-fundoc doc nil)))) (arglist (if docargs (cdar (read-from-string (downcase docargs))))) I hope the reason for EOF is now clear. (I have no idea why it only happens on master: the above bogus value shows on emacs-25 as well.) Does the following variant of string-match-p look right? Its intent is to limit the effect of inhibit-changing-match-data to the call to string-match only, leaving the error handling, if any is needed, outside of that binding. (defsubst string-match-p (regexp string &optional start) "\ Same as `string-match' except this function does not change the match data." (condition-case err (let ((inhibit-changing-match-data t)) (string-match regexp string start)) (error (signal (car err) (cdr err)))))