From: "Ludovic Courtès" <ludo@gnu.org>
To: Zhu Zihao <all_but_last@163.com>
Cc: guile-devel@gnu.org
Subject: Re: Send scheme procedure as callback to foreign thread.
Date: Wed, 12 Oct 2022 22:54:18 +0200 [thread overview]
Message-ID: <87r0zcu5j9.fsf@gnu.org> (raw)
In-Reply-To: <86zge2lv5w.fsf@163.com> (Zhu Zihao's message of "Tue, 11 Oct 2022 14:37:01 +0800")
Hi,
Zhu Zihao <all_but_last@163.com> skribis:
> In Guile FFI programming, we have procedure->pointer, which makes a
> Scheme procedure a foreign callback. And foreign library call use this
> callback.
>
> However, if this callback is called in a another foreign thread. The scheme
> context is not properly setup, It may cause crash or UB.
>
> IIUC, the procedure invoker "invoke_closure" defined in foreign.c
> doesn't use scm_with_guile. If we use scm_with_guile to make a foreign
> callback, would it be OK to execute Scheme procedure in multithreading context?
Yes, it should be.
Could you come up with a minimal reproducer and maybe even a fix, now
that you likely found the solution? :-)
Thanks in advance,
Ludo’.
PS: It may be best to use bug-guile to reduce the chances that the issue
gets lost.
next prev parent reply other threads:[~2022-10-12 20:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-11 6:37 Send scheme procedure as callback to foreign thread Zhu Zihao
2022-10-12 20:54 ` Ludovic Courtès [this message]
2022-10-13 16:28 ` Zhu Zihao
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=87r0zcu5j9.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=all_but_last@163.com \
--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).