Using guile 2.1.3, I have a program that:
- reads urls from a text file
- download the urls using curl command via popen
- output the result to stdout
Also, it relies on n-for-each-par-map for ice-9 threads.
IMO, the most suspicious is the definition of the `curl' proc:
(define (curl url)
(let* ((port (open-input-pipe (format #f "curl -is \"~a\"" url)))
(response (read-string port)))
(close-pipe port)
response))
I fail to see how this can leak.
To reproduce the bug you need a giant list of preferably different urls.
Such a list is available at http://hyperdev.fr/data/hn/hn.urls.txt.xz
You can run the test program with the following command:
cat hn.urls.txt | guile urls-step00-fetch.scm > /dev/null
This is not the only program I tried on guile-2.1.3 that leaks but
it's the easiest to reproduce.
I will try to reproduce the bug on 2.0.12.
(use-modules (ice-9 threads))
(use-modules (ice-9 rdelim))
(use-modules (ice-9 popen))
(use-modules (ice-9 rdelim))
;;; wrapping curl command
(define (curl url)
(let* ((port (open-input-pipe (format #f "curl -is \"~a\"" url)))
(response (read-string port)))
(close-pipe port)
response))
(define (maybe-curl url)
(catch #t
(lambda () (cons url (curl url)))
(lambda _ '())))
(define urls (let loop ((line (read-line))
(out '()))
(if (eof-object? line)
out
(loop (read-line) (cons line out)))))
(n-for-each-par-map 16 write maybe-curl urls)