[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Send scheme procedure as callback to foreign thread.
From: |
Ludovic Courtès |
Subject: |
Re: Send scheme procedure as callback to foreign thread. |
Date: |
Wed, 12 Oct 2022 22:54:18 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) |
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.