From: npostavs@users.sourceforge.net
To: Alan Mackenzie <acm@muc.de>
Cc: 28280@debbugs.gnu.org
Subject: bug#28280: Maximally unhelpful diagnostic message.
Date: Wed, 30 Aug 2017 08:17:24 -0400 [thread overview]
Message-ID: <874lsp8d2j.fsf@users.sourceforge.net> (raw)
In-Reply-To: <20170829201557.GB4339@ACM> (Alan Mackenzie's message of "Tue, 29 Aug 2017 20:15:57 +0000")
[-- Attachment #1: Type: text/plain, Size: 296 bytes --]
Alan Mackenzie <acm@muc.de> writes:
> Yes, but that's a separate problem from the essence of the bug report.
> Regardless of the lack of progress on bug #18913, the information
> provided by an assert being triggered is unhelpful and inadequate.
Here is a possible M-x cl-show-assert command:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 2695 bytes --]
From 835486ccfaaf58476cbb0e097bed3b81adbcfebe Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Wed, 30 Aug 2017 08:12:18 -0400
Subject: [PATCH v1] New command to backtrace from assertion failure
(Bug#28280)
* lisp/emacs-lisp/cl-lib.el (cl-show-assert): New command.
(cl-assert-last-backtrace): New variable.
* lisp/emacs-lisp/cl-preloaded.el (cl--assertion-failed): Set it.
TODO: keybinding? NEWS.
---
lisp/emacs-lisp/cl-lib.el | 15 +++++++++++++++
lisp/emacs-lisp/cl-preloaded.el | 10 ++++++++--
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/lisp/emacs-lisp/cl-lib.el b/lisp/emacs-lisp/cl-lib.el
index 243622a301..59bbdbca51 100644
--- a/lisp/emacs-lisp/cl-lib.el
+++ b/lisp/emacs-lisp/cl-lib.el
@@ -614,6 +614,21 @@ cl-pairlis
;;; Miscellaneous.
+(defvar cl-assert-last-backtrace nil
+ "Holds a list of frames from the last assertion failure.")
+
+(declare-function debugger-insert-backtrace "debug" (backtrace doxrefs))
+
+(defun cl-show-assert ()
+ "Show backtrace from last assertion failure."
+ (interactive)
+ (unless cl-assert-last-backtrace
+ (user-error "There hasn't been an assertion failure yet"))
+ (require 'debug)
+ (with-current-buffer (get-buffer-create "*Assertion Failure*")
+ (debugger-insert-backtrace cl-assert-last-backtrace t)
+ (display-buffer (current-buffer))))
+
(provide 'cl-lib)
(unless (load "cl-loaddefs" 'noerror 'quiet)
;; When bootstrapping, cl-loaddefs hasn't been built yet!
diff --git a/lisp/emacs-lisp/cl-preloaded.el b/lisp/emacs-lisp/cl-preloaded.el
index ab6354de7c..d66a4b9726 100644
--- a/lisp/emacs-lisp/cl-preloaded.el
+++ b/lisp/emacs-lisp/cl-preloaded.el
@@ -41,13 +41,19 @@
;; The `assert' macro from the cl package signals
;; `cl-assertion-failed' at runtime so always define it.
-(define-error 'cl-assertion-failed (purecopy "Assertion failed"))
+(define-error 'cl-assertion-failed (purecopy "Assertion failed (\\[cl-show-assert] for backtrace)"))
+
+(defvar cl-assert-last-backtrace)
(defun cl--assertion-failed (form &optional string sargs args)
(if debug-on-error
(funcall debugger 'error `(cl-assertion-failed (,form ,string ,@sargs)))
+ (setq cl-assert-last-backtrace (backtrace-frames 'cl--assertion-failed))
+ (autoload 'cl-show-assert "cl-lib"
+ "Show backtrace from last assertion failure." t)
(if string
- (apply #'error string (append sargs args))
+ (apply #'error (concat string " (\\[cl-show-assert] for backtrace)")
+ (append sargs args))
(signal 'cl-assertion-failed `(,form ,@sargs)))))
;; When we load this (compiled) file during pre-loading, the cl--struct-class
--
2.14.1
[-- Attachment #3: Type: text/plain, Size: 479 bytes --]
> That aside, I can't see how the two assertions suggested in #18913 could
> trigger the message I saw. I'll maybe have a look at the actual patch
> sometime when I'm less tired.
There is a third assertion added in [1: 62ee8b1a59] which is the one you
hit.
[1: 62ee8b1a59]: 2014-10-31 16:57:59 -0400
* lisp/simple.el (newline): Add assertions to try and help catch bug#18913.
http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=62ee8b1a59d5343197cb59d9f0a52e07a23af1d8
next prev parent reply other threads:[~2017-08-30 12:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-29 18:41 bug#28280: Maximally unhelpful diagnostic message Alan Mackenzie
2017-08-29 19:20 ` Glenn Morris
2017-08-29 19:32 ` John Wiegley
2017-08-29 20:15 ` Alan Mackenzie
2017-08-30 12:17 ` npostavs [this message]
2020-08-24 13:59 ` Lars Ingebrigtsen
2020-10-11 2:08 ` Lars Ingebrigtsen
2017-08-30 19:51 ` Glenn Morris
2017-08-31 21:11 ` Alan Mackenzie
2017-09-18 5:35 ` Paul Eggert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874lsp8d2j.fsf@users.sourceforge.net \
--to=npostavs@users.sourceforge.net \
--cc=28280@debbugs.gnu.org \
--cc=acm@muc.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.