unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Attila Lendvai <attila@lendvai.name>
To: Maxime Devos <maximedevos@telenet.be>
Cc: Christopher Baines <mail@cbaines.net>,
	"guile-devel@gnu.org" <guile-devel@gnu.org>,
	"46009@debbugs.gnu.org" <46009@debbugs.gnu.org>
Subject: RE: exception from inside false-if-exception?
Date: Mon, 17 Jun 2024 19:57:58 +0000	[thread overview]
Message-ID: <cKnzun5yW-Q_THEaSos_kxjOFWnNhitKD9PhgZpRW6mbC8NQmCFVnEtUsi8KtkaBBGoqpqpOIBT7U2FRRmk4CsZ2nFuaRdxxNcvHg9ErUt4=@lendvai.name> (raw)
In-Reply-To: <RpVsWsoGpFfNnEgFkKVrSOPG__6WbxYVUBWsiPaRB1qR9X3yTenQxN97VRRpCVokam6oNj9BEMSbSgcR2IFGm5UHC15rbaQk6KgrOPrW2Dc=@lendvai.name>

[-- Attachment #1: Type: text/plain, Size: 1436 bytes --]

apparently this has been fixed between 3.0.9 and HEAD. i've wasted my time chasing a ghost...

can we please have a new release? :)

as a sidenote, i also had some broken expectations in my test.scm.

it's a tangential, but namely, when #:unwind #t then the handler in a w-e-h returns from the w-e-h block, but with #:unwind #f it tries to return to the RAISE that raised the condition. i.e. a lousy little keyword arg (usually a page down) fundamentally changes the behavior of w-e-h. yet another surprise that violated my expectations regarding APIs.

anyway, i've attached a patch that clarifies what's happening for anyone who stumbles upon this; i.e. be clearer that (?) a backtrace is printed due to reaching a continuation barrier.

this makes it grep'able, and if the user also prints a backtrace, then it makes it clear that it's something printed by guile.

if someone wants to investigate further, then i'm also attaching a new version of my test.scm that behaves in an unexpected way on 3.0.9, but not on HEAD (more specifically on guile-next in guix, which is a rather recent commit).

HTH,

-- 
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
All men dream, but not equally. Those who dream by night in the dusty recesses of their minds wake in the day to find that it was vanity. But the dreamers of the day are dangerous men, for they may act their dream with open eyes to make it possible.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-More-specific-error-message-for-exceptions-at-contin.patch --]
[-- Type: text/x-patch; name=0001-More-specific-error-message-for-exceptions-at-contin.patch, Size: 933 bytes --]

From d45817097181d4a5812405474ac7b24af3531f7a Mon Sep 17 00:00:00 2001
From: Attila Lendvai <attila@lendvai.name>
Date: Mon, 17 Jun 2024 19:46:45 +0200
Subject: [PATCH] More specific error message for exceptions at continuation
 barriers

---
 libguile/continuations.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libguile/continuations.c b/libguile/continuations.c
index b8b6e1dca..49f8266dd 100644
--- a/libguile/continuations.c
+++ b/libguile/continuations.c
@@ -405,7 +405,7 @@ print_exception_and_backtrace (SCM port, SCM tag, SCM args)
 
   if (should_print_backtrace (tag, stack))
     {
-      scm_puts ("Backtrace:\n", port);
+      scm_puts ("An exception has reached a continuation barrier:\n", port);
       scm_display_backtrace_with_highlights (stack, port,
                                              SCM_BOOL_F, SCM_BOOL_F,
                                              SCM_EOL);
-- 
2.45.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: test.scm --]
[-- Type: text/x-scheme; name=test.scm, Size: 1431 bytes --]

#!/usr/bin/env -S guile --no-auto-compile -e main -s
!#

(use-modules (ice-9 control))

(define* (test #:key (unwind? #f))
  (let/ec return
    (with-exception-handler
        (let ((nested #f))
          (lambda (c-level-1)
            (if nested
                (begin
                  (format #t "level 1 handler got called recursively~%")
                  'level-1-handler-nested)
                (begin
                  (set! nested #t)
                  (with-exception-handler
                      (lambda (c-level-2)
                        (begin
                          (format #t "level 2 handler got error ~A~%" c-level-2)
                          (format #t "level 2 handler is returning~%")
                          (return 'level-2-handler)))
                    (lambda ()
                      (format #t "level 1 handler~%")
                      (error "let's signal a nested error...")
                      (format #t "level 1 handler is returning~%")
                      (return 'level-1-handler))
                    #:unwind? unwind?)))))
      (lambda ()
        (error "let's signal an error...")
        'thunk)
      #:unwind? unwind?)))

(define (main cmd)
  (unsetenv "COLUMNS")
  (format #t "~%~%*** calling with unwind~%")
  (format #t "return value is: ~A~%" (test #:unwind? #t))
  (format #t "~%~%*** calling without unwind~%")
  (format #t "return value is: ~A~%" (test #:unwind? #f)))

  reply	other threads:[~2024-06-17 19:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-29  9:06 exception from inside false-if-exception? Attila Lendvai
2024-04-29 14:13 ` bug#46009: " Maxime Devos
2024-04-29 14:22 ` Christopher Baines
2024-04-29 21:42   ` Attila Lendvai
2024-05-06 18:58     ` Maxime Devos
2024-06-12 16:32       ` Attila Lendvai
2024-06-17 19:57         ` Attila Lendvai [this message]
2024-06-17 20:50           ` Maxime Devos
2024-06-17 21:45             ` Attila Lendvai
2024-06-19 16:51               ` Maxime Devos
2024-06-19 18:58                 ` Attila Lendvai
2024-06-19 22:03                   ` Maxime Devos
2024-06-12 16:47       ` Attila Lendvai

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

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='cKnzun5yW-Q_THEaSos_kxjOFWnNhitKD9PhgZpRW6mbC8NQmCFVnEtUsi8KtkaBBGoqpqpOIBT7U2FRRmk4CsZ2nFuaRdxxNcvHg9ErUt4=@lendvai.name' \
    --to=attila@lendvai.name \
    --cc=46009@debbugs.gnu.org \
    --cc=guile-devel@gnu.org \
    --cc=mail@cbaines.net \
    --cc=maximedevos@telenet.be \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).