From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Redisplay hook error bactraces [Was: Fontification error backtrace] Date: Wed, 13 Jul 2022 15:13:41 -0400 Message-ID: References: <83sfnsadow.fsf@gnu.org> <83o7yg9f0w.fsf@gnu.org> <83r1396lvr.fsf@gnu.org> <83edz87ivz.fsf@gnu.org> <83r1375m6x.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20607"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Eli Zaretskii , larsi@gnus.org, emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jul 13 21:14:47 2022 Return-path: Envelope-to: ged-emacs-devel@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 1oBhot-0005AT-J8 for ged-emacs-devel@m.gmane-mx.org; Wed, 13 Jul 2022 21:14:47 +0200 Original-Received: from localhost ([::1]:58168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBhos-0005IH-4R for ged-emacs-devel@m.gmane-mx.org; Wed, 13 Jul 2022 15:14:46 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBhnx-0003uS-R5 for emacs-devel@gnu.org; Wed, 13 Jul 2022 15:13:49 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:49074) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBhnu-0001bh-Gt; Wed, 13 Jul 2022 15:13:47 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 7DA6944043B; Wed, 13 Jul 2022 15:13:44 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 0876E440169; Wed, 13 Jul 2022 15:13:43 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1657739623; bh=CfCenQrYWDt/gZ7hGWYUMmhP71CAkKxhX+DilyJA200=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=U5pnhrBOoxwvzyG/gJb9jgxKWUzcC3IiGOxMnBa/qXAAzSpypcCTyWPDQZaqZjHT3 dp+zshtQPdqqilURM6UzTbwAHo3eAQod1HKI61Wj/Btvs4r8jLFNT4GSJlrf2mCEDI 4fghWAh6QYiQ0DKN12SWfKiO57m5rkCHxNJR28KGx6Ad30FVHNlZOHWOmaxg6P4vm1 B+E8bHVQhXfP7B5IgZO4lvu/049BDMs3Ejzm3FUv4R/Y2Aq4Omb0hE/QZRyNgCPxQS v9i92LjPZVJ+pfsdDENEoLGd8tsmiLIOmRhFXXJsM6gIdYNFZVRT7AzHyCCUAljAik bWuk0pWffCG7w== Original-Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id E8D78120227; Wed, 13 Jul 2022 15:13:42 -0400 (EDT) In-Reply-To: (Alan Mackenzie's message of "Tue, 12 Jul 2022 19:48:49 +0000") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:292111 Archived-At: > + /* If an error is signalled during a Lisp hook in redisplay, write a > + backtrace into the buffer *Backtrace*. */ > + if (!debugger_called && !NILP (error_symbol) > + && redisplay_lisping > + && backtrace_on_redisplay_lisp_error > + && (!backtrace_yet || !NILP (Vredisplay_last_error)) > + && (NILP (clause) || h == redisplay_deep_handler) > + && NILP (Vinhibit_debugger) > + && !NILP (Ffboundp (Qdebug_early))) > + { > + max_ensure_room (&max_lisp_eval_depth, lisp_eval_depth, 100); > + specpdl_ref count = SPECPDL_INDEX (); > + ptrdiff_t counti = specpdl_ref_to_count (count); > + AUTO_STRING (backtrace, "*Backtrace*"); > + Lisp_Object backtrace_buffer; > + AUTO_STRING (gap, "\n\n\n\n"); /* Separates backtraces in *Backtrace* */ I really think that printing the backtrace right when the error is signaled is a bad idea. Better just copy the whole specpdl (or just the backtrace part of it) and leave the buffer manipulation and printing for later when we're back in a normal&sane context. It would be worthwhile doing all this work in the context of the error if there was an upside such as the ability to do the debugging "live", but since this is for the case where we'll be doing a "post-mortem debugging" anyway, we're much better off doing as little as possible in the context of the error: too many things can go wrong when running in the context of the error, it's asking for trouble. Stefan