* [Caml-list] Segmentation Fault on Mixing C and Ocaml thread
@ 2003-12-15 4:51 SooHyoung Oh
0 siblings, 0 replies; only message in thread
From: SooHyoung Oh @ 2003-12-15 4:51 UTC (permalink / raw)
To: Caml-List
[-- Attachment #1: Type: text/plain, Size: 1134 bytes --]
Hi!
On programming ocaml -> c -> ocaml applications using ocaml thread and C
pthread,
I met "Segmentation Fault" error on calling
ocaml thread -> c function -> c pthread -> callback() function.
Test examples are attatched.
Could anyone help me?
===============
(1) Ocaml thread -> c function
let thr_main ch () =
let running = ref true in
while !running do
match (sync (receive ch)) with
| Run -> run_cb ()
| Run_segfault -> run_cb_segfault ()
| Finish -> running := false
done
(2) run_cb () is "OK"
CAMLprim value run_cb (value unit)
{
CAMLparam1 (unit);
printf("--- run_cb\n"); fflush(stdout);
callback(g_closure, Val_unit);
CAMLreturn (Val_unit);
}
(3) run_cb_segfault() generates "Segmentation Fault"
void *thr_main (void *arg)
{
printf("--- thr_main\n");
callback(g_closure, Val_unit);
}
void create_thr()
{
pthread_t thr;
pthread_create(&thr, NULL, thr_main, NULL);
}
CAMLprim value run_cb_segfault (value unit)
{
CAMLparam1 (unit);
printf("--- run_cb_segfault\n"); fflush(stdout);
create_thr();
CAMLreturn (Val_unit);
}
---
SooHyoung Oh
[-- Attachment #2: tst.tgz --]
[-- Type: application/x-compressed, Size: 1098 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-12-15 4:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-15 4:51 [Caml-list] Segmentation Fault on Mixing C and Ocaml thread SooHyoung Oh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox