[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#30261: segfault on simultaneous initialization
From: |
Mark H Weaver |
Subject: |
bug#30261: segfault on simultaneous initialization |
Date: |
Sat, 27 Jan 2018 15:27:21 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) |
Sheheryar Parvaz <address@hidden> wrote:
> If the initial call to scm_with_guile is on a thread and in the main
> thread at the same time, a segmentation fault occurs.
Mark H Weaver <address@hidden> wrote:
> Yes, this is a known issue. At present, Guile must be fully initialized
> in one thread before it can be safely used from any other thread.
> Furthermore, when loading modules, you must ensure that no other thread
> attempts to load or use the same module while it's being loaded. If
> possible, please arrange to load all modules that your program will need
> before accessing Guile from other threads.
Sheheryar Parvaz <address@hidden> writes:
> Are there any decent workarounds for this? I considered
> scm_init_guile, however according to the documentation, it is
> non-portable. For modules, I have no idea how I would initialize them.
The usual approach is to initialize Guile before spawning any other
threads. You can do this by calling 'scm_with_guile' early in your
'main', and then moving most of the contents of your 'main' into the
inner function that 'scm_with_guile' calls.
If there are modules that you'll need to load from your threaded code,
then load them before spawning any threads, from within the inner
function that 'scm_with_guile' calls. From C, you can load modules with
'scm_c_resolve_module'.
Mark