From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 42B23BBAF for ; Mon, 23 Aug 2010 14:05:20 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhsBAEMBckwmachwl2dsb2JhbACgMBUBAQEBAQgVBzO4S4U3BA X-IronPort-AV: E=Sophos;i="4.56,257,1280700000"; d="scan'208";a="55912754" Received: from mx1.janestreet.com ([38.105.200.112]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 23 Aug 2010 14:05:08 +0200 Received: from nyc-imap.janestreet.com ([172.25.22.57] helo=nyc-qsv-mail1.delacy.com) by mx1.janestreet.com with esmtp (Exim 4.71) (envelope-from ) id 1OnVlx-0000rs-DC for caml-list@inria.fr; Mon, 23 Aug 2010 08:05:05 -0400 Received: from nyc-qsv-004.delacy.com ([172.25.22.194] helo=qsmtp.delacy.com) by nyc-qsv-mail1.delacy.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.71) (envelope-from ) id 1OnVlx-0006jv-AJ; Mon, 23 Aug 2010 08:05:05 -0400 Received: from ldn-qws-r01.delacy.com ([172.23.65.101]) by qsmtp.delacy.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.71) (envelope-from ) id 1OnVlw-0000TZ-8P; Mon, 23 Aug 2010 08:05:05 -0400 Received: from mshinwell by ldn-qws-r01.delacy.com with local (Exim 4.71) (envelope-from ) id 1OnVlv-0006J4-Fs; Mon, 23 Aug 2010 13:05:03 +0100 Date: Mon, 23 Aug 2010 13:05:03 +0100 From: Mark Shinwell To: Paul Steckler Cc: caml-list@inria.fr Subject: Re: [Caml-list] Segfaults with Dynlink with OCaml 3.11 Message-ID: <20100823120503.GH27059@janestreet.com> References: <4C725620.4070803@glondu.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-Spam: no; 0.00; shinwell:01 segfaults:01 dynlink:01 ocaml:01 steckler:01 bindings:01 segfaults:01 ocaml:01 bindings:01 camlparam:01 generational:01 gdb:01 backtrace:01 dynlink:01 23,:98 On Mon, Aug 23, 2010 at 09:47:43PM +1000, Paul Steckler wrote: > On Mon, Aug 23, 2010 at 9:06 PM, Stéphane Glondu wrote: > > Does your real large program use C bindings? Are you able to reproduce > > the segfaults with pure OCaml code? > > Yes, the large program has C bindings, including calls into dynamically loaded > .so files (Linux dynamic libraries). Anything I should look into for those? It can be a time-consuming task, but double-check all the rules on http://caml.inria.fr/pub/docs/manual-ocaml/manual032.html are being followed. For example, watch out for things like variables of type [value] that are wrongly not protected with CAMLlocal/CAMLparam macros across allocation points when the variable's contents are needed later, uses of the Field macro as an lvalue in a situation where instead Store_field must be used, assigning to generational global roots without using the correct function, etc. Just one minor transgression could be the cause of a hard-to-find error at some random point during program execution. Have you tried using gdb to determine the stack backtrace when it segfaults? Also, if it can be done without disturbing too much code, it might be worth trying to eliminate Dynlink from the program as a test. Mark