From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#61847: debug-early-backtrace only works some of the time. Date: Mon, 27 Feb 2023 17:11:51 +0000 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30359"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier To: 61847@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 27 18:13:23 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pWh3y-0007ip-Hg for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 27 Feb 2023 18:13:22 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pWh3h-0000u0-L8; Mon, 27 Feb 2023 12:13:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pWh3f-0000rS-4o for bug-gnu-emacs@gnu.org; Mon, 27 Feb 2023 12:13:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pWh3e-0005C3-Ql for bug-gnu-emacs@gnu.org; Mon, 27 Feb 2023 12:13:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pWh3e-0006Pd-4r for bug-gnu-emacs@gnu.org; Mon, 27 Feb 2023 12:13:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 27 Feb 2023 17:13:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 61847 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.167751793924593 (code B ref -1); Mon, 27 Feb 2023 17:13:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 27 Feb 2023 17:12:19 +0000 Original-Received: from localhost ([127.0.0.1]:48686 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pWh2w-0006Ob-Rt for submit@debbugs.gnu.org; Mon, 27 Feb 2023 12:12:19 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:36400) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pWh2q-0006OM-JH for submit@debbugs.gnu.org; Mon, 27 Feb 2023 12:12:16 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pWh2q-0008SX-Bp for bug-gnu-emacs@gnu.org; Mon, 27 Feb 2023 12:12:12 -0500 Original-Received: from mx3.muc.de ([193.149.48.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pWh2o-0004xc-8b for bug-gnu-emacs@gnu.org; Mon, 27 Feb 2023 12:12:12 -0500 Original-Received: (qmail 76316 invoked by uid 3782); 27 Feb 2023 18:11:51 +0100 Original-Received: from acm.muc.de (pd953acb4.dip0.t-ipconnect.de [217.83.172.180]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Mon, 27 Feb 2023 18:11:51 +0100 Original-Received: (qmail 25386 invoked by uid 1000); 27 Feb 2023 17:11:51 -0000 Content-Disposition: inline X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.5; envelope-from=acm@muc.de; helo=mx3.muc.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:256891 Archived-At: Hello, Emacs. In the master branch: Sometimes, instead of outputting a backtrace, debug-early throws an error, like the second line of: Error: cl-assertion-failed ((stringp typename)) Symbol's function definition is void: cl-defgeneric .. To reproduce this failure, apply the following patch to src/eval.c, then attempt a make bootstrap: diff --git a/src/eval.c b/src/eval.c index d42f7ffe894..8a88f5894b1 100644 --- a/src/eval.c +++ b/src/eval.c @@ -542,13 +542,13 @@ DEFUN ("function", Ffunction, Sfunction, 1, UNEVALLED, 0, && (EQ (QCdocumentation, XCAR (tmp)))) { /* Handle the special (:documentation
) to build the docstring dynamically. */ - Lisp_Object docstring = eval_sub (Fcar (XCDR (tmp))); - if (SYMBOLP (docstring) && !NILP (docstring)) - /* Hack for OClosures: Allow the docstring to be a symbol - * (the OClosure's type). */ - docstring = Fsymbol_name (docstring); - CHECK_STRING (docstring); - cdr = Fcons (XCAR (cdr), Fcons (docstring, XCDR (XCDR (cdr)))); + /* Lisp_Object docstring = eval_sub (Fcar (XCDR (tmp))); */ + /* if (SYMBOLP (docstring) && !NILP (docstring)) */ + /* /\* Hack for OClosures: Allow the docstring to be a symbol */ + /* * (the OClosure's type). *\/ */ + /* docstring = Fsymbol_name (docstring); */ + /* CHECK_STRING (docstring); */ + /* cdr = Fcons (XCAR (cdr), Fcons (docstring, XCDR (XCDR (cdr)))); */ } if (NILP (Vinternal_make_interpreted_closure_function)) return Fcons (Qclosure, Fcons (Vinternal_interpreter_environment, cdr)); .. The cause of the problem was patch commit 08108a856a544a80d11b1e9e437fe6c45e25adec Author: Stefan Monnier Date: Fri Apr 29 22:18:09 2022 -0400 debug-early: Print bytecode in a more manageable way * lisp/emacs-lisp/debug-early.el (debug-early-backtrace): Escape newlines to and bytecodes to make backtraces slightly more readable. Use `cl-prin1` when available. , which made debug-early.el dependent on arbitrarily nested Lisp code, in violation of its explicitly stated design goal to have _no_ dependence on Lisp code. Some of this Lisp simply fails to load. It's not clear why the patch was applied. I propose fixing the bug by restoring the code to having no such dependencies with the following patch: diff --git a/lisp/emacs-lisp/debug-early.el b/lisp/emacs-lisp/debug-early.el index 395498f2206..723269f3ea0 100644 --- a/lisp/emacs-lisp/debug-early.el +++ b/lisp/emacs-lisp/debug-early.el @@ -44,28 +44,21 @@ 'debug-early-backtrace (princ "\n") (let ((print-escape-newlines t) (print-escape-control-characters t) - (print-escape-nonascii t) - (prin1 (if (and (fboundp 'cl-prin1) - ;; If we're being called while - ;; bootstrapping, we won't be able to load - ;; cl-print. - (require 'cl-print nil t)) - #'cl-prin1 - #'prin1))) + (print-escape-nonascii t)) (mapbacktrace #'(lambda (evald func args _flags) (let ((args args)) (if evald (progn (princ " ") - (funcall prin1 func) + (prin1 func) (princ "(")) (progn (princ " (") (setq args (cons func args)))) (if args (while (progn - (funcall prin1 (car args)) + (prin1 (car args)) (setq args (cdr args))) (princ " "))) (princ ")\n"))))))) .. Any objections to applying this patch? -- Alan Mackenzie (Nuremberg, Germany).