unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Ricardo Wurmus <rekado@elephly.net>
To: 56665@debbugs.gnu.org
Subject: bug#56665: Segfault in SRFI-37 when raising ERROR in ARGS-FOLD.
Date: Wed, 20 Jul 2022 16:34:53 +0200	[thread overview]
Message-ID: <87y1wnsv2m.fsf@elephly.net> (raw)

Hi,

I got Guile to segfault in srfi-37.

Here’s a Guile script:

--8<---------------cut here---------------start------------->8---
#!/run/current-system/profile/bin/guile \
--no-auto-compile
!#

(use-modules (srfi srfi-1) (srfi srfi-37) (ice-9 match))

(define %options
  (list (option '("greet") #t #f
                (lambda (opt name arg result)
                  (alist-cons 'greet arg
                              (alist-delete 'greet result))))))

(define %default-options
  `((greet . "hello")))

(define (parse-options args)
  (args-fold
   args %options
   (lambda (opt name arg result)
     (pk 'unrecognized)
     (error "unrecognized option" name))
   (lambda (arg result)
     (pk 'extraneous)
     (error "extraneous argument" arg))
   %default-options))

(match (pk 'args (program-arguments))
  ((_ . rest)
   (let ((config (parse-options rest)))
     (pk 'no-segfault)))
  (_
   (pk 'usage)))
--8<---------------cut here---------------end--------------->8---

And here is how to make it segfault:

--8<---------------cut here---------------start------------->8---
./segfault.scm --greet=no --oh=crud

;;; (args ("./segfault.scm" "--greet=no" "--oh=crud"))

;;; (unrecognized)
Backtrace:
           4 (primitive-load "/path/to/./segfault.scm")
In ice-9/eval.scm:
   293:34  3 (_ #(#(#(#(#<directory (guile-user) 7fee48518c80> ("./segfault.scm" "--greet=no" "--oh=crud")) #<procedure failure ()>) "./segfault.scm" …) …))
In srfi/srfi-37.scm:
   113:18  2 (next-arg)
In unknown file:
           1 Segmentation fault
--8<---------------cut here---------------end--------------->8---

Looks like using ERROR in ARGS-FOLD leads to a segfault.

-- 
Ricardo





                 reply	other threads:[~2022-07-20 14:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=87y1wnsv2m.fsf@elephly.net \
    --to=rekado@elephly.net \
    --cc=56665@debbugs.gnu.org \
    /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).