unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* segfault in 1.7.91
@ 2006-02-17 11:18 Stanislav Ievlev
  2006-02-18 16:51 ` Ken Raeburn
  0 siblings, 1 reply; 3+ messages in thread
From: Stanislav Ievlev @ 2006-02-17 11:18 UTC (permalink / raw)


Greetings!

It is unable to call callback from thread in guile extension.

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

pthread_t dbus_tid;

void *start_test(void* user_data)
{
        scm_call_0((void*)(user_data));
}

SCM scm_test_thread(SCM arg)
{
        pthread_create(&dbus_tid,NULL,start_test,arg);
}

void scm_init_test(void)
{
        scm_c_define_gsubr("test-thread", 1, 0, 0,(SCM(*)())scm_test_thread);
}
--

testcase:
--
(dynamic-call "scm_init_test" (dynamic-link "libguile-thread.so"))

(define cb (lambda() (write "zzz!\n")))

(test-thread cb)

(pause)
--

how to reproduce:

$gcc -fpic -lpthread dbus.c -shared -o lguile-thread.so

---
guile
guile> (dynamic-call "scm_init_test" (dynamic-link "libguile-thread.so"))
guile> (define cb (lambda() (write "zzz!\n")))
guile> (test-thread cb)
Segmentation fault

--
With best regards
Stanislav Ievlev.



_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: segfault in 1.7.91
  2006-02-17 11:18 segfault in 1.7.91 Stanislav Ievlev
@ 2006-02-18 16:51 ` Ken Raeburn
  2006-02-20  9:00   ` Stanislav Ievlev
  0 siblings, 1 reply; 3+ messages in thread
From: Ken Raeburn @ 2006-02-18 16:51 UTC (permalink / raw)
  Cc: guile-devel

On Feb 17, 2006, at 06:18, Stanislav Ievlev wrote:

> Greetings!
>
> It is unable to call callback from thread in guile extension.

Does it work if you use scm_with_guile in that thread, as described  
in the documentation?

(from doc/ref/api-init.texi)
Each thread that wants to use functions from the Guile API needs to
put itself into guile mode with either @code{scm_with_guile} or
@code{scm_init_guile}.  The global state of Guile is initialized
automatically when the first thread enters guile mode.

Ken


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: segfault in 1.7.91
  2006-02-18 16:51 ` Ken Raeburn
@ 2006-02-20  9:00   ` Stanislav Ievlev
  0 siblings, 0 replies; 3+ messages in thread
From: Stanislav Ievlev @ 2006-02-20  9:00 UTC (permalink / raw)
  Cc: guile-devel

On Sat, Feb 18, 2006 at 11:51:48AM -0500, Ken Raeburn wrote:
> On Feb 17, 2006, at 06:18, Stanislav Ievlev wrote:
> 
> >Greetings!
> >
> >It is unable to call callback from thread in guile extension.
> 
> Does it work if you use scm_with_guile in that thread, as described  
> in the documentation?
All works well now. Thank you.

--
With best regards
Stanislav Ievlev.



_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-02-20  9:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-17 11:18 segfault in 1.7.91 Stanislav Ievlev
2006-02-18 16:51 ` Ken Raeburn
2006-02-20  9:00   ` Stanislav Ievlev

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).