* [bug #20814] Issues with multithreading (using pthread, libguile 1.8.2)
@ 2007-08-18 17:36 anonymous
2007-08-18 20:16 ` anonymous
0 siblings, 1 reply; 8+ messages in thread
From: anonymous @ 2007-08-18 17:36 UTC (permalink / raw)
To: bug-guile
URL:
<http://savannah.gnu.org/bugs/?20814>
Summary: Issues with multithreading (using pthread, libguile
1.8.2)
Project: Guile
Submitted by: None
Submitted on: Saturday 08/18/2007 at 17:36 UTC
Category: None
Severity: 3 - Normal
Item Group: None
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
_______________________________________________________
Details:
Hello,
I hope I haven't misinterpreted the Guile Reference Manual, Edition 1.1, but
as I understand section 4.3.5 on using Guile with a multi-threaded C
application, it would be possible to execute a program's main loop, written
entirely in C, in one thread while running a Guile REPL in another thread
while interpreting Guile scripts in another.
If I do try to do this or execute any scm_* functions in 2 threads at the
same time, the result apparently is a segmentation fault, a stack overflow or,
in case of attempting to use scm_spawn_thread in one thread to spawn the
others, an error message stating "Function not implemented".
The latter error message seems to be exclusively related to use of
scm_spawn_thread, whereas any of the rest of the list of errors accompanies
any usage of scm functions in two threads simultaneously, even if such usage
is merely "scm_c_eval_string("(+ 5 6)");".
I'd like to ask you if any of this is related to a bug with guile 1.8.2 or if
what I'd like to do is as of yet impossible. If necessary, I'll clarify
anything that needs clarification and if I'm wasting your time and
misunderstood the manual, I apologize in advance.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?20814>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 8+ messages in thread
* [bug #20814] Issues with multithreading (using pthread, libguile 1.8.2)
2007-08-18 17:36 [bug #20814] Issues with multithreading (using pthread, libguile 1.8.2) anonymous
@ 2007-08-18 20:16 ` anonymous
2007-08-20 7:47 ` Ludovic Courtès
0 siblings, 1 reply; 8+ messages in thread
From: anonymous @ 2007-08-18 20:16 UTC (permalink / raw)
To: bug-guile
Follow-up Comment #1, bug #20814 (project guile):
Just to clarify, the scm_* functions are called in a function called with
scm_with_guile, so the threads calling scm_* functions are in guile mode.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?20814>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 8+ messages in thread
* [bug #20814] Issues with multithreading (using pthread, libguile 1.8.2)
2007-08-18 20:16 ` anonymous
@ 2007-08-20 7:47 ` Ludovic Courtès
2007-08-20 8:48 ` anonymous
0 siblings, 1 reply; 8+ messages in thread
From: Ludovic Courtès @ 2007-08-20 7:47 UTC (permalink / raw)
To: Ludovic Courtès, bug-guile
Follow-up Comment #2, bug #20814 (project guile):
Hi,
Can you please post sample code so that we have a clear idea of what you're
doing?
Also, what platform is this on?
Thanks,
Ludovic.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?20814>
_______________________________________________
Message posté via/par Savannah
http://savannah.gnu.org/
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 8+ messages in thread
* [bug #20814] Issues with multithreading (using pthread, libguile 1.8.2)
2007-08-20 7:47 ` Ludovic Courtès
@ 2007-08-20 8:48 ` anonymous
2007-08-20 9:17 ` anonymous
0 siblings, 1 reply; 8+ messages in thread
From: anonymous @ 2007-08-20 8:48 UTC (permalink / raw)
To: Ludovic Courtès, bug-guile
Follow-up Comment #3, bug #20814 (project guile):
Hi
Of course, the simplest sample code that refuses to run is the following:
#include <libguile.h>
void* scm_test (void* l){
SCM_TICK;
scm_c_eval_string("(write (+ 6 5)) (newline)");
}
int main(int argc, char** argv){
pthread_t blah;
scm_init_guile();
pthread_create(&blah, 0,scm_test,0);
while(1)
{
SCM_TICK;
scm_c_primitive_load("test.scm");
}
}
This is running on Kubuntu GNU/Linux, here's the output of uname -a:
Linux zero-desktop 2.6.20-16-generic #2 SMP Thu Jun 7 20:19:32 UTC 2007 i686
GNU/Linux
Interestingly, the above sample code has a different problem, namely:
./a.out:
Symbol `scm_i_thread_key' has different size in shared object, consider
re-linking
Segmentatiefout (core dumped)
The above might be a specific problem with my guile installation.
The other code with its amount of thread-safety issues (i.e. my original
program with some guile additions), has a rather large amount of non-guile
related code in it, so I'll omit that in the sample code for now, but,
condensed, it'd come down to roughly:
void* guile_main(void* arglet){
scm_shell(0,0);
}
void* run_guile(void* func){
scm_with_guile(func,0);
}
pthread_t guile_exec_thread(void* func){
pthread_t thread;
pthread_create(&thread,NULL,run_guile,func);
}
int
main (int argc, char **argv)
{
//misc initialization
guile_exec_thread(guile_main);
scm_init_guile();
while (1)
{
SCM_TICK;
//the body of a game's drawing loop (uses loads of OpenGL and other
non-guile calls)
scm_c_primitive_load("test.scm");
//sleep until the next frame
}
return 0;
}
I'll provide more information if necessary and for now, I'll recompile guile
to see if that would fix my first problem.
Thanks for taking the time to discuss this.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?20814>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 8+ messages in thread
* [bug #20814] Issues with multithreading (using pthread, libguile 1.8.2)
2007-08-20 8:48 ` anonymous
@ 2007-08-20 9:17 ` anonymous
2007-08-20 9:22 ` Ludovic Courtès
0 siblings, 1 reply; 8+ messages in thread
From: anonymous @ 2007-08-20 9:17 UTC (permalink / raw)
To: Ludovic Courtès, bug-guile
Follow-up Comment #4, bug #20814 (project guile):
Hi,
I've recompiled libguile from source (the original library I was using was
part of Kubuntu's guile-libs package), removing the symbol size difference
problem, so I suppose that's a bug with the lib I had originally installed and
not a generic guile bug. The top snippet's behavior now mirrors the behavior
of the bottom one , meaning it receives SIGSEGV after a while, but otherwise
seems to be able to evaluate s-expressions just fine.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?20814>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 8+ messages in thread
* [bug #20814] Issues with multithreading (using pthread, libguile 1.8.2)
2007-08-20 9:17 ` anonymous
@ 2007-08-20 9:22 ` Ludovic Courtès
2007-08-20 9:34 ` anonymous
0 siblings, 1 reply; 8+ messages in thread
From: Ludovic Courtès @ 2007-08-20 9:22 UTC (permalink / raw)
To: Ludovic Courtès, bug-guile
Follow-up Comment #5, bug #20814 (project guile):
Hi,
In your first example, the thread that executes `scm_test ()' is not in Guile
mode (see `scm_with_guile'), hence the segfault I suppose.
In your second example, I suspect you have two initializations going in
parallel. I'd rather first call `scm_init_guile ()' and _then_ call
`guile_exec_thread ()'. Can you tell us whether that fixes the problem?
Thanks,
Ludovic.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?20814>
_______________________________________________
Message posté via/par Savannah
http://savannah.gnu.org/
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 8+ messages in thread
* [bug #20814] Issues with multithreading (using pthread, libguile 1.8.2)
2007-08-20 9:22 ` Ludovic Courtès
@ 2007-08-20 9:34 ` anonymous
2007-08-20 9:48 ` Ludovic Courtès
0 siblings, 1 reply; 8+ messages in thread
From: anonymous @ 2007-08-20 9:34 UTC (permalink / raw)
To: Ludovic Courtès, bug-guile
Follow-up Comment #6, bug #20814 (project guile):
Hi,
Thanks for the reply.. now let's see...
Yes, the problem with the first example is indeed lack of guile mode in
scm_test(), fixed by reworking it to call scm_init_guile() first, after which
it enters a loop evaluating stuff, which just happily keeps on going. It works
now, thanks.
You were right again on the second one, it works now too.
Thanks a lot for helping me out here.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?20814>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 8+ messages in thread
* [bug #20814] Issues with multithreading (using pthread, libguile 1.8.2)
2007-08-20 9:34 ` anonymous
@ 2007-08-20 9:48 ` Ludovic Courtès
0 siblings, 0 replies; 8+ messages in thread
From: Ludovic Courtès @ 2007-08-20 9:48 UTC (permalink / raw)
To: Ludovic Courtès, bug-guile
Update of bug #20814 (project guile):
Open/Closed: Open => Closed
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?20814>
_______________________________________________
Message posté via/par Savannah
http://savannah.gnu.org/
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2007-08-20 9:48 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-18 17:36 [bug #20814] Issues with multithreading (using pthread, libguile 1.8.2) anonymous
2007-08-18 20:16 ` anonymous
2007-08-20 7:47 ` Ludovic Courtès
2007-08-20 8:48 ` anonymous
2007-08-20 9:17 ` anonymous
2007-08-20 9:22 ` Ludovic Courtès
2007-08-20 9:34 ` anonymous
2007-08-20 9:48 ` Ludovic Courtès
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).