From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id FAA10261; Mon, 15 Dec 2003 05:51:49 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id FAA10239 for ; Mon, 15 Dec 2003 05:51:48 +0100 (MET) Received: from miritek.com (miritek.com [210.107.136.75]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id hBF4pj110796 for ; Mon, 15 Dec 2003 05:51:46 +0100 (MET) Received: from hama (v36-99.icu.ac.kr [210.107.136.99]) by miritek.com (8.9.3/8.9.3) with SMTP id OAA05019 for ; Mon, 15 Dec 2003 14:03:23 +0900 Message-ID: <005c01c3c2c7$1fc76eb0$63886bd2@hama> From: "SooHyoung Oh" To: "Caml-List" Subject: [Caml-list] Segmentation Fault on Mixing C and Ocaml thread Date: Mon, 15 Dec 2003 13:51:12 +0900 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0057_01C3C312.8085B5E0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Loop: caml-list@inria.fr X-Spam: no; 0.00; callback:01 segfault:01 segfault:01 camlprim:01 camlparam:01 printf:01 fflush:01 stdout:01 callback:01 val:01 camlreturn:01 val:01 printf:01 camlprim:01 camlparam:01 X-Attachments: cset="ks_c_5601-1987" type="application/x-compressed" name="tst.tgz" name="tst.tgz" Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk This is a multi-part message in MIME format. ------=_NextPart_000_0057_01C3C312.8085B5E0 Content-Type: text/plain; charset="ks_c_5601-1987" Content-Transfer-Encoding: 7bit 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 ------=_NextPart_000_0057_01C3C312.8085B5E0 Content-Type: application/x-compressed; name="tst.tgz" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="tst.tgz" H4sIAN483T8AA+1X/0/jNhTn1/iveOumU4Jo1lJopfZA4xCcboLdRGHaD5Mq47pNdo5dJU6B293/ vme7SQOjnDQN0CR/pKb2+/rxc/yS8KWOM7H1rOh0O53+3t5WBzHo3/9HdPu9/a3OYNAf7Pb2e7t7 xn6wO9iCzvPScigLTXOArSJRyVN239L/T6EWXMJlknM6JXZ8suRSE8JvNc8lFZDzeVrgeMKuhxCW MtXQPgTzH1UDOIBWw6zVcC6l9Wu6WWsr/4fhpODzGS2F3uRRG7QI0XcLDnxptBelhC/mWutxeprK tEgIEVyDTvJJRlMJLIEwggMSGCnGlKmcY4Ccz0DnJYdUkuAmSQWH7yrtVJEgyKg2rsWdZBDmnPF0 yTFYFMFNqhM0sOkNYUcUs1TCNadauxatzBzXlYHNOjyAGRUFJ8FUSe5WwXCXNG8sACkdgOQ3E5ZQ KbkwKrMCt2TUuY2NK8dGGaLKFoU7Zu5SSKXT2R1UQphSTatszSJauSECriQFl9NK7uJuTr0yClcp /1QorRPWnK1Yr/ZvkadSu3y/muEstpIZtBIuhNqBG5WL6R+yNYKZKLGShZ6qUjtnm3ZdNGSCYda1 NGQbd6/LNSLBqhTGHHcRBeE2jPk8w+NBdaoknNod3I4emta7ez+I22OUrVaWO3aTak38lsXM3mYr woS8wPln1zF77hzf6v97/br/93f3bf/v9Xq+/78Evk8lE+WUw1s8MqmKk0OyFi20O4sobEgZzcSP mVhSUfLivoNT8Uzld48oGBXimrJPNp51h/mECVWUOR8Rcnx0foaHLwOnap7J0ImMbUT+IoE1pTnN uhBaIboHriWErXa73XTGrhBhW7B9IXR9wZrXJnOhrqmY5Erp8E1NCG2CemIaBo6Mm0mdc13meER/ Qzf7JByRr7gilU5hu250oZvTfG4pN9lVNpYaCaq6hHW+HXgktGtZE3QOXUS3OxPb0kbrubML3+B0 B365OjvbqRO6uYv5sNwPn0xObDk8LPmK2P2K3/d/vOpBcw2jp4r5KLt/SWoTl6fL/gS51z60/yHO 6Sc+w/ed58xh+39/Y//vDHrduv+bxt/pdnHk+/9L4PTs6P0Y21vbNQ8yvjg2U24/C8nHdz+bGb4k KPghNLohig9ilqmIXB5dvD+5RLUuNDn78M5Y4hm5RS0FF64wY3J8Nb78eG6SMKy2ygjBkzfEgC4C vuhgBDM36fB1SpmnBcO5c4xwZGniBwfS+AmnJltUOxDcwSEJzD6y5QzasI0k8cKgurvxc2D+OV0g ATg0dGM9/0wIE5xKdMwzaOcz45Cl9qrwqpr8pnwxXPHCoYt/CDGO8b2XkOoxVwvi8dXp6YffT8ZD MKb4S8HGtSmQWKxIzGI1bCy2WiKO32KETBiHjQYmpAm20eC1bywPDw8PDw8PDw8PDw8PDw8PDw8P Dw8Pj1fD31KYt8sAKAAA ------=_NextPart_000_0057_01C3C312.8085B5E0-- ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners