From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 816277FACB for ; Sun, 14 Sep 2014 09:41:23 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of mjambon@gmail.com) identity=pra; client-ip=209.85.220.54; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="mjambon@gmail.com"; x-sender="mjambon@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of mjambon@gmail.com designates 209.85.220.54 as permitted sender) identity=mailfrom; client-ip=209.85.220.54; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="mjambon@gmail.com"; x-sender="mjambon@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-pa0-f54.google.com) identity=helo; client-ip=209.85.220.54; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="mjambon@gmail.com"; x-sender="postmaster@mail-pa0-f54.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApQBAKxFFVTRVdw2lGdsb2JhbABgg2BXgny2SI98iFMWEAEBAQEHCwsJEiyEBAEBBBIRDwEFCAE3AQEDDAEFBRgCAgUWCwICCQMCAQIBIgEFARwGDQEHAQEXB4gIAxEFCJVta4swhQKIWycNhnUSAQUOgR6IVIhMgVMFiz+HEYM0iGOFaIc9hElBgWyDQ0yCSgEBAQ X-IPAS-Result: ApQBAKxFFVTRVdw2lGdsb2JhbABgg2BXgny2SI98iFMWEAEBAQEHCwsJEiyEBAEBBBIRDwEFCAE3AQEDDAEFBRgCAgUWCwICCQMCAQIBIgEFARwGDQEHAQEXB4gIAxEFCJVta4swhQKIWycNhnUSAQUOgR6IVIhMgVMFiz+HEYM0iGOFaIc9hElBgWyDQ0yCSgEBAQ X-IronPort-AV: E=Sophos;i="5.04,520,1406584800"; d="scan'208";a="79103113" Received: from mail-pa0-f54.google.com ([209.85.220.54]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 14 Sep 2014 09:41:22 +0200 Received: by mail-pa0-f54.google.com with SMTP id lj1so4395174pab.27 for ; Sun, 14 Sep 2014 00:41:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=Jf0ZyIkJgmfgAnsONuLLN6CiZhW59/yAOuaGeqFFbnU=; b=U/CUA9L8UbLZLBSsMPHmC23LrZB0UtPBjnKMZgC0h5FyjDFDN5xgwgmNaV3l3s2qOm MdkgEY8jidQltzym22H+P1NLp2+WP22cQVj1L7nNDyMmsDIjJdYglULuEhNovmLgfoy4 vvrarmcGj21ky04vUe1oG6Rg6fn3gGPsid4+l1Ar/pA6rjq3oFMRCKF90pjyF0OYPtNi Q2oB4GwZq967qvSdqtCL8Mm1MBYbSxsLF2tyRS9m7PaLLc7RZIRXt+edfKNRJugWLYyr /YExi5DBVpop6CHPV+JIYtYMltbXC8B36FslEq5SZYRWsSRpws1sufggryfdUJzZoj66 WUyg== X-Received: by 10.70.48.97 with SMTP id k1mr1502811pdn.135.1410680480759; Sun, 14 Sep 2014 00:41:20 -0700 (PDT) Received: from [192.168.2.7] (c-67-180-86-2.hsd1.ca.comcast.net. [67.180.86.2]) by mx.google.com with ESMTPSA id ad10sm8549620pad.4.2014.09.14.00.41.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 14 Sep 2014 00:41:20 -0700 (PDT) Sender: Martin Jambon Message-ID: <5415469D.8050604@ens-lyon.org> Date: Sun, 14 Sep 2014 00:41:17 -0700 From: Martin Jambon User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: Alain Frisch CC: Caml List , Jeremy Yallop References: <20140905215626.GB3416@annexia.org> <20140905221302.GE3099@annexia.org> <20140905221813.GC3416@annexia.org> <540A3B85.6010609@ens-lyon.org> <540AA0DB.1040202@ens-lyon.org> <540CA84F.8090708@frisch.fr> <540D0642.7090205@ens-lyon.org> <54141BCF.60801@ens-lyon.org> In-Reply-To: <54141BCF.60801@ens-lyon.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Caml-list] segfault in simple program with 4.02 native On 09/13/2014 03:26 AM, Martin Jambon wrote: > On Sun 07 Sep 2014 06:28:34 PM PDT, Martin Jambon wrote: >> On Sun 07 Sep 2014 11:47:43 AM PDT, Alain Frisch wrote: >>> On 9/6/2014 7:51 AM, Martin Jambon wrote: >>>> Thanks for the explanation, Jeremy. I guess atdgen will have to use >>>> "option refs" after all unless someone has a better idea. >>> >>> I might be missing some context, but the current code seems to playing >>> two different tricks with the type system: using (Obj.magic 0.) as a >>> dummy initial default value (to avoid references) and mutating >>> normally immutable fields with Obj.set_field. Is that right? >> >> Yes, exactly. >> >>> You >>> might be able to keep the first trick, but storing the values in local >>> references instead of field of the the target record (if those >>> references don't espace from the function, they will be represented as >>> local mutable variables, whose mutation might actually be more >>> efficient than those of the record fields), building the target >>> record at the end by reading from those references. >> >> Christophe Troestler also suggested this solution in a private reply. >> I was afraid of the cost of the refs, so it's great to know that >> they're optimized away. > > I think we now have a working implementation for json readers in atdgen > (https://github.com/mjambon/atdgen/tree/fix-magic-ocaml402). > > However, atdgen also supports a binary format called biniou (Intro: > http://mjambon.com/biniou.html Spec: > https://github.com/mjambon/biniou/blob/master/biniou-format.txt). It is > broken for the same reason as the JSON readers, but it is trickier to > fix. Biniou allows sharing records and cyclic data. So far readers have > been working by first creating a record with uninitialized fields, and > then by proceeding with reading the field values. If a reference to the > record is found, we just use the record that we already created, even if > some of its fields are still unset. > > The problem here is that we need to create the record before reading its > fields. Perhaps we could use the solution proposed by Milan Stanojević > earlier in this thread, consisting in creating a private record type > with mutable fields and at the end convert it to the normal type using > Obj.magic. > > ... Or we could just drop support for some features, hence the following > questions: > > 1. Does anyone use biniou at all? > 2. Does anyone use biniou with cyclic data? atdgen 1.4.0 is out (soon in opam). It should work with OCaml 4.02 for both json and biniou. I dropped support for sharing, so no more support for serialization of cyclic data using biniou. Martin