caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gerd Stolpmann <info@gerd-stolpmann.de>
To: "Markus Weißmann" <markus.weissmann@in.tum.de>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Obj.out_of_heap_tag, out of minor heap or memory corruption?
Date: Fri, 29 Apr 2016 16:25:17 +0200	[thread overview]
Message-ID: <1461939917.9915.110.camel@e130.lan.sumadev.de> (raw)
In-Reply-To: <5630123afc948279fc61d5e4c35d9014@in.tum.de>

[-- Attachment #1: Type: text/plain, Size: 2337 bytes --]

Am Freitag, den 29.04.2016, 16:14 +0200 schrieb Markus Weißmann:
> The value comes from C bindings, but from a string-value via Char.code.
> It is then passed through a constructor-function to create the record;
> I added a check there to see if the C bindings are to blame:

Well, there are other types of errors in C bindings that could also
cause this. Imagine what happens when the C bindings do not properly
handle pointers (e.g. do not declare them as local roots), and an
outdated pointer to an int is followed by the GC because of this.
Because the minor GC moves values to the major heap, this could cause
that the int is overwritten then.

In my experience, it's always the C binding!

Unfortunately, there's no code for investigations.

Gerd


> 
>    type foo = { a : int; b : int }
> 
>    let create (a : int) (b : int) =
>      assert (Obj.is_int (Obj.repr x)); (* always holds *)
>      { a; b }
> 
> This assertion never triggered so far.
> I replaced the equality check by a function which now also asserts the
> is_int property:
> 
>    let equal (x : foo) (y : foo) = (* y is a static value living through 
> the entire run; x is from a parse/allocate/compare/throw-away cycle *)
>      assert (Obj.is_int (Obj.repr x.a));
>      assert (Obj.is_int (Obj.repr y.a));
>      assert (Obj.is_int (Obj.repr x.b)); (* <- this fails after a while 
> *)
>      assert (Obj.is_int (Obj.repr y.b));
>      x = y
> 
> and one of these (always the same) triggers after a while (after some 
> 10.000 calls).
> But only with the standard minor heap size, not with a 4 MB sized one.
> There are no other functions working on these values; they are parsed, 
> put through
> the constructor function, compared and thrown away.
> 
> Regards
> Markus
> 
> --
> Markus Weißmann, M.Sc.
> Technische Universität München
> Institut für Informatik
> Boltzmannstr. 3
> D-85748 Garching
> Germany
> http://wwwknoll.in.tum.de/

-- 
------------------------------------------------------------
Gerd Stolpmann, Darmstadt, Germany    gerd@gerd-stolpmann.de
My OCaml site:          http://www.camlcity.org
Contact details:        http://www.camlcity.org/contact.html
Company homepage:       http://www.gerd-stolpmann.de
------------------------------------------------------------


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2016-04-29 14:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-29 11:04 Markus Weißmann
2016-04-29 13:17 ` Gerd Stolpmann
2016-04-29 14:14   ` Markus Weißmann
2016-04-29 14:25     ` Gerd Stolpmann [this message]
2016-05-02  8:27       ` Sébastien Hinderer
2016-05-02 14:30         ` Gabriel Scherer
2016-05-03 15:59           ` Boris Yakobowski
2016-04-29 14:57     ` Mark Shinwell
2016-04-29 15:41       ` Markus Weißmann
2016-04-29 16:41         ` Adrien Nader

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=1461939917.9915.110.camel@e130.lan.sumadev.de \
    --to=info@gerd-stolpmann.de \
    --cc=caml-list@inria.fr \
    --cc=markus.weissmann@in.tum.de \
    /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).