Hi, I am having problems using libguile in a multi-threaded environment, which boils down to the following small test case, which fails with a segmentation fault with guile-2.0.9:
#include <libguile.h> #include <pthread.h> void *guile_wrapper (void *data) { scm_c_eval_string ("(display \"Hello\n\")"); return NULL; } void *thread_func (void *data) { scm_with_guile (&guile_wrapper, NULL); return NULL; } int main () { pthread_t thread1; pthread_t thread2; pthread_create (&thread1, NULL, thread_func, NULL); pthread_create (&thread2, NULL, thread_func, NULL); pthread_join (thread1, NULL); pthread_join (thread2, NULL); return 0; } However, it prints "Hello" correctly if only one thread is started. It seems that scm_with_guile() is not thread safe in the form used above. However the following suggest that it should be: http://www.gnu.org/software/guile/manual/html_node/Multi_002dThreading.html#Multi_002dThreading http://www.gnu.org/software/guile/manual/html_node/Initialization.html#Initialization I am clearly doing something wrong, which is probably obvious to others. Can anyone help me with this? Perhaps I have to serialize use of scm_with_guile() notwithstanding what is said in the documentation, but if so it will be disappointing for the use to which I was hoping to put it. Chris