unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Zhu Zihao <all_but_last@163.com>
To: guile-devel <guile-devel@gnu.org>
Subject: Send scheme procedure as callback to foreign thread.
Date: Tue, 11 Oct 2022 14:37:01 +0800	[thread overview]
Message-ID: <86zge2lv5w.fsf@163.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 616 bytes --]

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?
-- 
Retrieve my PGP public key:

  gpg --recv-keys B3EBC086AB0EBC0F45E0B4D433DB374BCEE4D9DC

Zihao

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 255 bytes --]

             reply	other threads:[~2022-10-11  6:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-11  6:37 Zhu Zihao [this message]
2022-10-12 20:54 ` Send scheme procedure as callback to foreign thread Ludovic Courtès
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=86zge2lv5w.fsf@163.com \
    --to=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).