caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Martin Jambon <martin.jambon@ens-lyon.org>
To: caml-list@inria.fr
Subject: Re: [Caml-list] segfault in simple program with 4.02 native
Date: Fri, 05 Sep 2014 15:39:01 -0700	[thread overview]
Message-ID: <540A3B85.6010609@ens-lyon.org> (raw)
In-Reply-To: <20140905221813.GC3416@annexia.org>

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 <field name> = 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


  parent reply	other threads:[~2014-09-05 22:39 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-05 21:33 Ashish Agarwal
2014-09-05 21:50 ` Andy Ray
2014-09-05 21:56 ` Richard W.M. Jones
2014-09-05 22:01   ` Sebastien Mondet
2014-09-05 22:06   ` Ashish Agarwal
2014-09-05 22:13     ` Richard W.M. Jones
2014-09-05 22:18       ` Richard W.M. Jones
2014-09-05 22:36         ` Török Edwin
2014-09-05 22:39         ` Martin Jambon [this message]
2014-09-05 23:39           ` Ashish Agarwal
2014-09-05 23:59             ` Martin Jambon
2014-09-06  0:12           ` Jeremy Yallop
2014-09-06  5:51             ` Martin Jambon
2014-09-06  6:00               ` Milan Stanojević
2014-09-06  7:46                 ` Frédéric Bour
2014-09-06 19:15                   ` Martin Jambon
2014-09-06 19:08                 ` Martin Jambon
2014-09-06 20:31                   ` David MENTRÉ
2014-09-06 21:57                     ` Martin Jambon
2014-09-07  7:34                       ` David MENTRÉ
2014-09-07 18:47               ` Alain Frisch
2014-09-08  1:28                 ` Martin Jambon
2014-09-13 10:26                   ` Martin Jambon
2014-09-14  7:41                     ` Martin Jambon
2014-09-05 22:18       ` Christoph Höger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=540A3B85.6010609@ens-lyon.org \
    --to=martin.jambon@ens-lyon.org \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).