From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id E1BCBBC37 for ; Sun, 27 Dec 2009 13:20:03 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ai8EADbgNktV2gB5h2dsb2JhbACDaZUrgkYBAQEKCwgHFYg7nxqNI4Evgi5WBIkl X-IronPort-AV: E=Sophos;i="4.47,458,1257116400"; d="scan'208";a="52839554" Received: from emailfrontal2.citycable.ch ([85.218.0.121]) by mail4-smtp-sop.national.inria.fr with SMTP; 27 Dec 2009 13:19:39 +0100 Received: from [192.168.0.12] (unknown [85.218.92.99]) (Authenticated sender: guillaume.yziquel@citycable.ch) by emailfrontal2.citycable.ch (Postfix) with ESMTPA id 79C5D834338; Sun, 27 Dec 2009 13:19:34 +0100 (CET) Message-ID: <4B3750D8.8000209@citycable.ch> Date: Sun, 27 Dec 2009 13:19:36 +0100 From: Guillaume Yziquel Reply-To: guillaume.yziquel@citycable.ch User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090707) MIME-Version: 1.0 To: ygrek Cc: OCaml List Subject: Re: [Caml-list] Wrapping C code using pthread. References: <4B352731.2060306@citycable.ch> <20091227114253.a0a9ff49.ygrekheretix@gmail.com> In-Reply-To: <20091227114253.a0a9ff49.ygrekheretix@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; guillaume:01 guillaume:01 segfaults:01 ocaml:01 segfaults:01 ocaml:01 callbacks:01 pointer:01 bytecode:01 segfault:01 bytecode:01 2009:98 wrote:01 caml-list:01 caml:02 ygrek a =C3=A9crit : > On Fri, 25 Dec 2009 21:57:21 +0100 > Guillaume Yziquel wrote: >=20 >> Hello. >> >> I'm currently trying to wrap up together a C interface for the MonetDB= 5=20 >> database system. I'm getting quite a lot of segfaults (a lot of which=20 >> come from MonetDB itself), and I'm therefore wondering the following=20 >> about pthreads and OCaml: >> >> The server is started via a pthread: >> >> pthread_create(&sqlthread, NULL, start_sql_server, (void *) server); >> >> and I would like to know what kind of things I should look at with=20 >> C-side pthreads in order to avoid segfaults... >=20 > How does the OCaml code gets executed? Via callbacks from this thread? > If so, have a look at http://caml.inria.fr/mantis/view.php?id=3D4702 Thanks for the pointer. No this is not the case. In fact, it's a library that starts an embedded=20 database server in its own pthread. Completely distinct from OCaml. In fact, my trouble is that when things are compiled to native code, it=20 works fine. However, things get screwed up when compiled to bytecode,=20 resulting in a segfault. Are pthreads compatible with OCaml bytecode? All the best, --=20 Guillaume Yziquel http://yziquel.homelinux.org/