Here is a minimal example reproducing the problem.
Note that it only fails the first time (when scheme.scm is compiled).
Note: I put bug-guile on CC, hoping it will not trash the attachments,
because with this example I'm starting to believe there is something
wrong going on.
CFLAGS += $(shell guile-config compile) -std=c99
LDLIBS += $(shell guile-config link) -lpthread
all: main
clean:
rm -f *.o main
(define-module (test))
(use-modules (system base compile))
(define prog '(lambda (a b c)
(+ a b c)))
(define (f)
(compile prog)
(display "done\n"))
#include <stdlib.h>
#include <pthread.h>
#include <libguile.h>
static void *eval_string(void *str)
{
SCM module = scm_c_resolve_module("guile-user");
(void)scm_c_eval_string_in_module(str, module);
return NULL;
}
static void *do_call_f(void *name)
{
SCM module = scm_c_resolve_module("test");
SCM proc_var = scm_c_module_lookup(module, name);
SCM proc = scm_variable_ref(proc_var);
(void)scm_call_0(proc);
return NULL;
}
void *thread(void *arg)
{
(void)arg;
scm_with_guile(do_call_f, "f");
return NULL;
}
int main(void)
{
pthread_t pt;
scm_with_guile(eval_string, "(load \"scheme.scm\")");
pthread_create(&pt, NULL, thread, NULL);
pthread_join(pt, NULL);
return 0;
}