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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 86EA87FACB for ; Sat, 6 Sep 2014 01:40:16 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of agarwal1975@gmail.com) identity=pra; client-ip=209.85.216.48; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="agarwal1975@gmail.com"; x-sender="agarwal1975@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of agarwal1975@gmail.com designates 209.85.216.48 as permitted sender) identity=mailfrom; client-ip=209.85.216.48; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="agarwal1975@gmail.com"; x-sender="agarwal1975@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-qa0-f48.google.com) identity=helo; client-ip=209.85.216.48; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="agarwal1975@gmail.com"; x-sender="postmaster@mail-qa0-f48.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ar4BAPNIClTRVdgwm2dsb2JhbABagkeBGVcEgnivf5Q9gWmHTAF8CBYQAQEBAQEGCwsJFCmEAwEBAQMBEhEdARsSCwEDAQsGAwILDQ0dAgIiAREBBQEKEgYTEhCICwEDCQgNjTiQKGuLK4FygxCJBgoZJwMKZoV0AREBBQ6OeEMEB4J5gVMBBIUKBZBfhn6BXJFYGCmCeYI1IS+CTwEBAQ X-IPAS-Result: Ar4BAPNIClTRVdgwm2dsb2JhbABagkeBGVcEgnivf5Q9gWmHTAF8CBYQAQEBAQEGCwsJFCmEAwEBAQMBEhEdARsSCwEDAQsGAwILDQ0dAgIiAREBBQEKEgYTEhCICwEDCQgNjTiQKGuLK4FygxCJBgoZJwMKZoV0AREBBQ6OeEMEB4J5gVMBBIUKBZBfhn6BXJFYGCmCeYI1IS+CTwEBAQ X-IronPort-AV: E=Sophos;i="5.04,476,1406584800"; d="scan'208";a="93262136" Received: from mail-qa0-f48.google.com ([209.85.216.48]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 06 Sep 2014 01:40:15 +0200 Received: by mail-qa0-f48.google.com with SMTP id m5so11922089qaj.35 for ; Fri, 05 Sep 2014 16:40:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=7qPPp5uda7Pap/5nNkNxWyHXXOqvqomPjooH6X5YoKY=; b=oiHnN8sz2n5HRgtEm9+426PURKit1sLdjSPaET/lqLFLAezDF8hZk9KEnw6NbtyYQC iEq6llSEp4Tc6frLf7F6qDRCTR8t0WFOSTSb50uq4aM/4cMjB96sELiZzGFcKF5QMoZQ MPmhcwQtpIFYmCy0V8lO1LXDlHBDaU6509kA9dXVgImXWCWdcDXzqmoIeQUjuJ+CZ2Cw 5D6noNuLaEi/VTED0u+ubs/IeuFL74prvZL0U9q5xsFJYm3Z+kPw6U1VXK++Qg4GabuH adFP/E0cbVv8nabjBoXo24jYlNyR5rVUov8GDaXiM1h7Lqh1JK9cnhe5exw1yDaBCYsB mikg== X-Received: by 10.229.100.69 with SMTP id x5mr11372756qcn.6.1409960414614; Fri, 05 Sep 2014 16:40:14 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.138.15 with HTTP; Fri, 5 Sep 2014 16:39:54 -0700 (PDT) In-Reply-To: <540A3B85.6010609@ens-lyon.org> References: <20140905215626.GB3416@annexia.org> <20140905221302.GE3099@annexia.org> <20140905221813.GC3416@annexia.org> <540A3B85.6010609@ens-lyon.org> From: Ashish Agarwal Date: Fri, 5 Sep 2014 19:39:54 -0400 Message-ID: To: Martin Jambon Cc: Caml List Content-Type: multipart/alternative; boundary=001a11337970a91aec050259fdac Subject: Re: [Caml-list] segfault in simple program with 4.02 native --001a11337970a91aec050259fdac Content-Type: text/plain; charset=UTF-8 > First try a 'make test' from atdgen's source ... The following tests failed: ocaml internals biniou correctness json correctness *** FAILURE *** Thanks to everyone for all the replies. My type defs are small, so at least I can easily bypass the issue by using Yojson directly. On Fri, Sep 5, 2014 at 6:39 PM, Martin Jambon wrote: > On 09/05/2014 03:18 PM, Richard W.M. Jones wrote: > >> On Fri, Sep 05, 2014 at 11:13:02PM +0100, Richard W.M. Jones wrote: >> >>> On Fri, Sep 05, 2014 at 06:06:55PM -0400, Ashish Agarwal wrote: >>> >>>> I increased the stack size to 65532, which is apparently the max >>>> allowed on >>>> a Mac, and it doesn't change the behavior. >>>> >>> >>> Yup. I was able to reproduce this on the non-core version, and indeed >>> increasing the stack to unlimited on Linux does not help. >>> >>> The stack trace is simple: >>> >>> #0 0x00000000004543f4 in camlPervasives__output_string_1198 () >>> #1 0x0000000000472093 in camlCamlinternalFormat__output_acc_60624 () >>> #2 0x0000000000473a32 in camlPrintf__fun_1062 () >>> #3 0x000000000041e776 in camlApp__entry () >>> #4 0x000000000041c5f9 in caml_program () >>> #5 0x0000000000497f7e in caml_start_program () >>> #6 0x000000000049813d in __libc_csu_init () >>> #7 0x00007ffff7317d65 in __libc_start_main () from /lib64/libc.so.6 >>> #8 0x000000000041c2e9 in _start () >>> >>> I'm just installing debuginfo so I can get more symbols .. >>> >> >> .. although I guess the fact that the generated code in config_j.ml is >> doing a lot of Obj.magic would be the first place to be suspicious. >> >> eg: >> >> let (x : postgres) = >> { >> host = Obj.magic 0.0; >> ... >> >> where the host field has declared type string. Really? >> > > That code is generated by atdgen. What happens is that we have to either > create an empty record when starting to parse a list of unordered JSON > fields, or use a bunch `let = ref None in` for each field and > create the record in the end. While the latter approach is not much more > work to implement, the resulting code was found to be significantly slower. > > The reason why it's using `Obj.magic 0.0` is that it worked in all cases > (and has been for the past 4 years). Obtaining a well-formed constant value > for any type is not trivial, so this what we have. > > It's very possible that it's now broken with OCaml 4.02. First try a 'make > test' from atdgen's source directory (https://github.com/mjambon/atdgen) > and see if it passes. > > > Martin > > > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > --001a11337970a91aec050259fdac Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
>=C2=A0=C2=A0First try a 'make test' from atdgen's source<= br>...
The following tests failed:
ocaml internals
biniou c= orrectness
json correctness
*** FAILURE ***

Thanks= to everyone for all the replies. My type defs are small, so at least I can= easily bypass the issue by using Yojson directly.




On Fri, Sep 5, 2014 at 6:39 PM, Martin Jambon <martin.jambon@= ens-lyon.org> wrote:
On 09/05/2014 03:18 PM, Richard W.M. Jone= s wrote:
On Fri, Sep 05, 2014 at 11:13:02PM +0100, Richard W.M. Jones wrote:
On Fri, Sep 05, 2014 at 06:06:55PM -0400, Ashish Agarwal wrote:
I increased the stack size to 65532, which is apparently the max allowed on=
a Mac, and it doesn't change the behavior.

Yup.=C2=A0 I was able to reproduce this on the non-core version, and indeed=
increasing the stack to unlimited on Linux does not help.

The stack trace is simple:

#0=C2=A0 0x00000000004543f4 in camlPervasives__output_string_1198 ()=
#1=C2=A0 0x0000000000472093 in camlCamlinternalFormat__output_acc_60= 624 ()
#2=C2=A0 0x0000000000473a32 in camlPrintf__fun_1062 ()
#3=C2=A0 0x000000000041e776 in camlApp__entry ()
#4=C2=A0 0x000000000041c5f9 in caml_program ()
#5=C2=A0 0x0000000000497f7e in caml_start_program ()
#6=C2=A0 0x000000000049813d in __libc_csu_init ()
#7=C2=A0 0x00007ffff7317d65 in __libc_start_main () from /lib64/libc.so.6 #8=C2=A0 0x000000000041c2e9 in _start ()

I'm just installing debuginfo so I can get more symbols ..

.. although I guess the fact that the generated code in config_j.ml is
doing a lot of Obj.magic would be the first place to be suspicious.

eg:

=C2=A0 =C2=A0 =C2=A0let (x : postgres) =3D
=C2=A0 =C2=A0 =C2=A0 =C2=A0{
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0host =3D Obj.magic 0.0;
...

where the host field has declared type string.=C2=A0 Really?

That code is generated by atdgen. What happens is that we have to either cr= eate an empty record when starting to parse a list of unordered JSON fields= , or use a bunch `let <field name> =3D ref None in` for each field an= d create the record in the end. While the latter approach is not much more = work to implement, the resulting code was found to be significantly slower.=

The reason why it's using `Obj.magic 0.0` is that it worked in all case= s (and has been for the past 4 years). Obtaining a well-formed constant val= ue for any type is not trivial, so this what we have.

It's very possible that it's now broken with OCaml 4.02. First try = a 'make test' from atdgen's source directory (https://github.com/mjambon/<= u>atdgen) and see if it passes.


Martin

--001a11337970a91aec050259fdac--