Subject: bug#33229: n-for-each-par-map crash guile 2.2.4

From: Amirouche Boubekki <[email-masked]>
Date: Thu, 01 Nov 2018 19:21:33 +0100

On my machine with 4 procs the following program crash after a while:

(define-module (hn))

(use-modules (srfi srfi-1))
(use-modules (ice-9 receive))
(use-modules (ice-9 threads))
(use-modules (ice-9 iconv))
(use-modules (web client))
(use-modules (json))

(define (max-id)
   (receive (response body) (http-get 
"https://hacker-news.firebaseio.com/v0/maxitem.json")
            (string->number (bytevector->string body "utf-8"))))

(define (download uid)
   (catch #t
          (lambda ()
            (let* ((uid (1+ uid))
                   (url 
"https://hacker-news.firebaseio.com/v0/item/~a.json")
              (url (format #f url uid)))
         (cons uid
               (json-string->scm
                (call-with-values (lambda () (http-get url))
                  (lambda (response body)
                    (bytevector->string body "utf-8")))))))
     (lambda _ '())))

(define (store pair)
   (if (null? pair)
       (format #t "X\n")
       (let ((port (open-file "hn.scm" "a")))
         (format #t "~a\n" (car pair))
         (write (cdr pair) port)
         (close port))))

(define (dump)
   (n-for-each-par-map 32 store download (reverse (iota (max-id)))))

(dump)

I attached to the program with its dependency json.scm.

Mark asked for this report at 
https://lists.gnu.org/archive/html/guile-devel/2018-07/msg00017.html

I will try guile 3.0 and report back.