From: Mark H Weaver <mhw@netris.org>
To: Amirouche Boubekki <amirouche@hypermove.net>
Cc: Guile Devel <guile-devel@gnu.org>
Subject: Re: (n-for-each-par-map 16 store download (reverse (iota (max-id))))) crash
Date: Thu, 05 Jul 2018 14:30:28 -0400 [thread overview]
Message-ID: <871schk01n.fsf@netris.org> (raw)
In-Reply-To: <567d1b31558c2b51908d8a272ff61494@hypermove.net> (Amirouche Boubekki's message of "Thu, 05 Jul 2018 13:28:58 +0200")
Hi,
Amirouche Boubekki <amirouche@hypermove.net> writes:
> I have a program that try to download hackernews locally.
>
> What it does is simple, it fetch the max identifier and
> http-get each json value starting with the most recent
> item. I use n-for-each-par-map with 16 threads I have
> 8 cores.
>
> Here is the full program:
[...]
> (define (store pair)
> (if (null? pair)
> (format #t "X\n")
> (let ((port (open-file "hn.scm" "a")))
> (format #t "~a\n" (car pair))
These calls to (format #t ...), which write to a port that is shared by
multiple threads, should be performed while holding a mutex to prevent
concurrent writes to the same port.
I/O operations in Guile do not include built-in thread synchronization,
at least not in the fast path cases. However, an effort was made to
avoid _crashes_ on common architectures in the event of concurrent use
of the same port. Our hope was that the worst that would typically
happen is garbled I/O. Perhaps we failed to realize that hope.
> How can I debug this?
It would be helpful to see a GDB backtrace from a crash in this program.
Does it help to protect the shared port with a mutex?
Thanks,
Mark
next prev parent reply other threads:[~2018-07-05 18:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-05 11:28 (n-for-each-par-map 16 store download (reverse (iota (max-id))))) crash Amirouche Boubekki
2018-07-05 18:30 ` Mark H Weaver [this message]
2018-07-06 5:55 ` Amirouche Boubekki
2018-07-06 7:01 ` Mark H Weaver
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=871schk01n.fsf@netris.org \
--to=mhw@netris.org \
--cc=amirouche@hypermove.net \
--cc=guile-devel@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).