Segfault in SRFI-37 when raising ERROR in ARGS-FOLD.

  • Open
  • quality assurance status badge
Details
One participant
  • Ricardo Wurmus
Owner
unassigned
Submitted by
Ricardo Wurmus
Severity
normal
R
R
Ricardo Wurmus wrote on 20 Jul 2022 16:34
(address . bug-guile@gnu.org)
87y1wnsv2m.fsf@elephly.net
Hi,

I got Guile to segfault in srfi-37.

Here’s a Guile script:

Toggle snippet (34 lines)
#!/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)))

And here is how to make it segfault:

Toggle snippet (15 lines)
./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

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

--
Ricardo
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 56665@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 56665
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch