From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Helmut Eller Newsgroups: gmane.emacs.bugs Subject: bug#24617: 26.0.50; Handlers in `condition-case' should have programmatic access to the backtrace Date: Wed, 05 Oct 2016 08:16:46 +0200 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1475648310 16475 195.159.176.226 (5 Oct 2016 06:18:30 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 5 Oct 2016 06:18:30 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) To: 24617@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Oct 05 08:18:26 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1brfWw-0002Dq-87 for geb-bug-gnu-emacs@m.gmane.org; Wed, 05 Oct 2016 08:18:14 +0200 Original-Received: from localhost ([::1]:46689 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brfWu-0006Fo-PC for geb-bug-gnu-emacs@m.gmane.org; Wed, 05 Oct 2016 02:18:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36730) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brfWn-0006FV-QS for bug-gnu-emacs@gnu.org; Wed, 05 Oct 2016 02:18:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brfWk-0006Vk-KL for bug-gnu-emacs@gnu.org; Wed, 05 Oct 2016 02:18:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:38920) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brfWk-0006Vf-HN for bug-gnu-emacs@gnu.org; Wed, 05 Oct 2016 02:18:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1brfWk-0003UD-A2 for bug-gnu-emacs@gnu.org; Wed, 05 Oct 2016 02:18:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Helmut Eller Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 05 Oct 2016 06:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24617 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.147564825413354 (code B ref -1); Wed, 05 Oct 2016 06:18:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 5 Oct 2016 06:17:34 +0000 Original-Received: from localhost ([127.0.0.1]:45110 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1brfWI-0003TK-Gq for submit@debbugs.gnu.org; Wed, 05 Oct 2016 02:17:34 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:45555) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1brfWG-0003T4-UD for submit@debbugs.gnu.org; Wed, 05 Oct 2016 02:17:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brfWA-0006EI-Pp for submit@debbugs.gnu.org; Wed, 05 Oct 2016 02:17:27 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:34879) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brfWA-0006E6-NU for submit@debbugs.gnu.org; Wed, 05 Oct 2016 02:17:26 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36518) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brfW8-0006CJ-B5 for bug-gnu-emacs@gnu.org; Wed, 05 Oct 2016 02:17:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brfW4-0006Bp-0Z for bug-gnu-emacs@gnu.org; Wed, 05 Oct 2016 02:17:23 -0400 Original-Received: from [195.159.176.226] (port=52848 helo=blaine.gmane.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brfW3-00068B-Pp for bug-gnu-emacs@gnu.org; Wed, 05 Oct 2016 02:17:19 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1brfVs-0002PS-OK for bug-gnu-emacs@gnu.org; Wed, 05 Oct 2016 08:17:08 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 26 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:jEZ7Zh/RJ63pVl3FhadKxu5DB90= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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:124084 Archived-At: On Tue, Oct 04 2016, Philipp Stephani wrote: > Currently a handler in a `condition-case' form doesn't have access to > the backtrace that was active when the signal was raised. This makes > many useful things impossible, such as re-raising signals or returning > the backtrace to emacsclient. I suggest either adding true exception > objects (storing the error symbol, data, and backtrace), or at least > providing a dynamic variable with the current backtrace. First, you can copy the backtrace in a signal-hook-function and store it in global variable. Second, unconditionally copying the backtrace would be expensive and would still not allow access to local variables in stack frames or the value of dynamic variables at the point where the error was signalled Just because Java or Python do that doesn't make it a great idea. Third, the solution to this problem in Common Lisp is the HANDLER-CASE macro which is similar to condition-case but the error handlers are executed without unwinding the stack. That doesn't require any copying and gives full access to the stack. (Again, can be emulated with a signal-hook-function.) Of course, that approach can't be used to handle things like stack overflow or only if done very carefully. Helmut