Hello,

I am having a problem with threads in 1.8.3 .

The offending program:

------------------
#include <pthread.h>
#include <libguile.h>

void * thread_inner_main (void * unused)
{
  int argc = 0;
  char* argv[] = { 0 };
  scm_shell (argc, argv);

  return NULL; /* dummy */
}

void * thread_main (void * unused)
{
  scm_with_guile (&thread_inner_main, NULL);

  return NULL; /* dummy */
}

void * inner_main (void * unused)
{
  pthread_t thread;

  pthread_create (&thread, NULL, &thread_main, NULL);
  pthread_join (thread, NULL);

  return NULL; /* dummy */
}

int main (int argc, char **argv)
{
  sc m_with_guile (&inner_main, NULL);

  return 0;
}
------------------

This produces the following output:

------------------
Backtrace:
In unknown file:
   ?: 14* (if (or # #) (try-load-module name))
   ?: 15  [try-load-module (ice-9 readline)]
   ?: 16  (or (begin (try-module-linked name)) (try-module-autoload
   name) ...)
   ?: 17* [try-module-autoload (ice-9 readline)]
   ?: 18  (let* (# # # #) (resolve-module dir-hint-module-name {#f})
   (and # #))
   ?: 19* [resolve-module (ice-9) {#f}]
   ?: 20  (let* ((full-name #)) (let* (#) (if already # #)))
    ...
   ?: 21  (cond ((module-ref module # {#f}) => (lambda # #)) (else
   (let* # # # ...)))
   ?: 22* [module-ref {#f} %app {#f}]
   ?: 23  (let* ((variable #)) (if (and variable #) (variable-ref
   variable) ...))
   ?: 24* [module-variable {#f} %app]
   ?: 25  [module-search #<procedure module-local-variable (m v)> {#f}
   %app]
    ...
   ?: 26  (or (fn m v) (loop (module-uses m)))
   ?: 27* [module-local-variable {#f} %app]
   ?: 28  (let* ((b #)) (or (and # b) (and # #)))
   ?: 29* [module-obarray-ref ...
   ?: 30*  [module-obarray {#f}]
   ?: 31   (if (eq? # #) (struct-ref obj 0) (%record-type-error #
   obj))
   ?: 32*  [eq? ...
   ?: 33*   [struct-vtable {#f}]

<unnamed port>: In procedure struct-vtable in expression
(struct-vtable obj):
<unnamed port>: Wrong type argument in position 1 (expecting struct):
#f
------------------

It seems that for some reason you cannot load modules from a different thread than the one which first initialized guile.

Any idea how to get this to work ?

Thanks in advance.


P.S.
I used 'pthread_create' instead of 'scm_spawn_thread' for
simplification because for some reason 'join-thread' has no C
equivalent. But maybe I am missing something here as well ?


Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail