GNU bug report logs -
#30261
segfault on simultaneous initialization
Previous Next
To reply to this bug, email your comments to 30261 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-guile <at> gnu.org
:
bug#30261
; Package
guile
.
(Fri, 26 Jan 2018 17:38:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Sheheryar Parvaz <skipper308 <at> hotmail.ca>
:
New bug report received and forwarded. Copy sent to
bug-guile <at> gnu.org
.
(Fri, 26 Jan 2018 17:38:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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.
#include <pthread.h>
#include <libguile.h>
void* hello_world(void *arg) {
scm_c_eval_string("(display \"Hello World!\")");
scm_c_eval_string("(newline)");
}
void run_guile() {
scm_with_guile(&hello_world, NULL);
}
int main(int argc, char **argv) {
pthread_t th;
int ret = pthread_create(&th, NULL, &run_guile, NULL);
run_guile();
pthread_join(&th, NULL);
return 0;
}
Here is a backtrace of the issue.
#0 0x00007ffff7afd976 in scm_set_current_dynamic_state () from /usr/lib/libguile-2.2.so.1
#1 0x00007ffff7b5faec in guilify_self_2 () from /usr/lib/libguile-2.2.so.1
#2 0x00007ffff7b604b4 in scm_i_init_thread_for_guile () from /usr/lib/libguile-2.2.so.1
#3 0x00007ffff7b604f9 in with_guile () from /usr/lib/libguile-2.2.so.1
#4 0x00007ffff7281312 in GC_call_with_stack_base () from /usr/lib/libgc.so.1
#5 0x00007ffff7b60918 in scm_with_guile () from /usr/lib/libguile-2.2.so.1
#6 0x00000000004007a3 in run_guile ()
#7 0x00007ffff7893568 in start_thread (arg=0x7ffff5ea8700) at pthread_create.c:465
#8 0x00007ffff75cb52f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-guile <at> gnu.org
:
bug#30261
; Package
guile
.
(Fri, 26 Jan 2018 23:44:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 30261 <at> debbugs.gnu.org (full text, mbox):
Hi,
Sheheryar Parvaz <skipper308 <at> hotmail.ca> writes:
> 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.
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.
We'd like to fix this at some point, but for various reasons it's a
non-trivial project.
Thanks,
Mark
Information forwarded
to
bug-guile <at> gnu.org
:
bug#30261
; Package
guile
.
(Sat, 27 Jan 2018 01:18:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 30261 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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.
________________________________
From: Mark H Weaver <mhw <at> netris.org>
Sent: January 26, 2018 6:41 PM
To: Sheheryar Parvaz
Cc: 30261 <at> debbugs.gnu.org
Subject: Re: bug#30261: segfault on simultaneous initialization
Hi,
Sheheryar Parvaz <skipper308 <at> hotmail.ca> writes:
> 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.
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.
We'd like to fix this at some point, but for various reasons it's a
non-trivial project.
Thanks,
Mark
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-guile <at> gnu.org
:
bug#30261
; Package
guile
.
(Sat, 27 Jan 2018 20:29:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 30261 <at> debbugs.gnu.org (full text, mbox):
Sheheryar Parvaz <skipper308 <at> hotmail.ca> 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 <mhw <at> netris.org> 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 <skipper308 <at> hotmail.ca> 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
This bug report was last modified 7 years and 138 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.