caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Philippe Veber <philippe.veber@googlemail.com>
To: Romain Beauxis <toots@rastageeks.org>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Tips to find the cause of a seg fault
Date: Wed, 1 Dec 2010 16:17:15 +0100	[thread overview]
Message-ID: <AANLkTikedG6DHZNQDrgG3uGaWGxwh4zkaSGeS=4R99z5@mail.gmail.com> (raw)
In-Reply-To: <201011301959.04218.toots@rastageeks.org>

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

2010/12/1 Romain Beauxis <toots@rastageeks.org>

> Hi,
>
> Le mardi 30 novembre 2010 17:08:12, Philippe Veber a écrit :
> > The seg fault occurs during the call to this function with the button
> event
> > retrieved by ocamlsdl. What's really weird is that if I comment the third
> > case of the pattern matching, the seg fault does not occur. This is
> strange
> > since with the "assert false" expression, I make sure this case is
> useless
> > (i don't press the left button). Also, in the various tests I made, I
> > obtained different errors, like segmentation fault in caml_absf_mask or
> > invalid instruction error.
>
> The function that triggers the segfault may be confusing, in particular in
> case of a memory corruption, which I suspect here.
> The pattern matching can cause a crash because it is using a value that is
> already corrupted and because the third case is one that, for some random
> conditions, touches the part in memory that is corrupted.
>
How is this possible if it is never reached (no left click) ?


>
> In this case, I would try to unroll the code and see where the value that
> is
> used in this function was instanciated.
>
What do you mean by "unrolling the code" ?



>
> Main source of corruption when using C bindings most often come from either
> the Gc or code executed while the global lock has been released.
>
> In the case of a segfault hapenning during a Gc call, this can be really
> unrelated, for instance the instanciation of a new value triggers a Gc
> collection to compact memory, which in turns triggers the recollection of a
> corrupted value, which causes a segfault.
>
> In the case of a segfault hapenning during a C call while the global lock
> has
> been released, you may get more useful informations through gdb, in
> particular
> the trace of the C code used at the time of the segfault. You need have the
> debugging symbols for the dynamic C libraries used as well.
>
> We experienced a couple of segfault with ocaml SDL too but in unrelated
> parts
> (video). I do not mean to criticize upstream's work on ocaml SDL because I
> know for a fact that these types of bindings are really hard to code.
> However,
> I would suspect an issue there.
>
> Finally, the best approach could be to actually look closely to the
> binding's
> code and try to spot anything fishy there related to your issue. This
> generaly
> worked better for me than trying to get information from gdb and the like..
>

Many thanks for the clarification. Maybe I could (partially) "unplug" the GC
by setting space_overhead to 100 ? That could give an indication on the
moment the problem occurs ?
ph.

[-- Attachment #2: Type: text/html, Size: 3454 bytes --]

  reply	other threads:[~2010-12-01 15:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-30 23:08 Philippe Veber
2010-11-30 23:18 ` [Caml-list] " oliver
2010-12-01  8:32   ` Philippe Veber
2010-12-01  9:15     ` oliver
2010-12-01 10:26       ` Philippe Veber
2010-12-01 10:51         ` oliver
2010-12-01 15:08           ` Philippe Veber
2010-12-01  1:59 ` Romain Beauxis
2010-12-01 15:17   ` Philippe Veber [this message]
2010-12-01 15:27     ` oliver
2010-12-01 16:15     ` Romain Beauxis
2010-12-01  5:51 ` Ilya Seleznev
2010-12-01 15:21   ` Philippe Veber
     [not found] <1182061596.483210.1291158525016.JavaMail.root@zmbs1.inria.fr>
2010-12-03 15:43 ` Damien Doligez
2010-12-05 14:50   ` Philippe Veber

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='AANLkTikedG6DHZNQDrgG3uGaWGxwh4zkaSGeS=4R99z5@mail.gmail.com' \
    --to=philippe.veber@googlemail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=toots@rastageeks.org \
    /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).