caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Philippe Veber <philippe.veber@googlemail.com>
To: Damien Doligez <damien.doligez@inria.fr>
Cc: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] Tips to find the cause of a seg fault
Date: Sun, 5 Dec 2010 15:50:34 +0100	[thread overview]
Message-ID: <AANLkTimUSh8YMyxcJM3XpKDfF3f78dhaUGd14ofmA=De@mail.gmail.com> (raw)
In-Reply-To: <3474B264-1D16-4740-B935-995B6B38F0CE@inria.fr>

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

Thanks everyone for your answers. For the record, I finally understood the
cause of my problem: first I noticed that I had no segfault on the same
machine replacing my touchpad with a usual mouse. I then wrote a C
equivalent of my minimal program, which worked perfectly (also according to
valgrind). This basically meant the problem lied in the binding. So I
finally checked at the C level every mouse event incoming and saw that there
were mouse button events containing unexpected mouse button codes. These
codes corresponded to horizontal two finger scrolling, that is indeed not
available on a standard mouse, and not incorporated in ocamlsdl API. The
thing is that button codes are used directly to encode variants in the
binding and, as a consequence used to compute a jump in the pattern
matching. So what happened is the following: by using vertical two finger
scrolling a bit too fast, I would also generate (unintentionally) an
horizontal scrolling event at the end of my move, and right after that do a
pattern matching on its variant representation, which triggered a jump in
some unexpected zone of memory, leading to either segmentation fault or
illegal instruction error.

So, long story short: doing pattern matching on mouse events of ocamlsdl (or
the sdl binding of glcaml, by the way) may lead to a crash when using a
touchpad. For now I'll use a cheap workaround in my program, but if the
authors of ocamlsdl are interested, I'll gladly work on a patch.

cheers,
ph.


2010/12/3 Damien Doligez <damien.doligez@inria.fr>

>
> On 2010-12-01, at 00:08, Philippe Veber wrote:
>
> > Short story (details below): I'm currently writing a program relying on
> react, lablgl and ocamlsdl. This program segfaults on my laptop under two
> linux distributions (ubuntu and gentoo) but doesn't on a PC under ubuntu.
> The seg fault occurs with both bytecode and native executables. I don't do
> any marshaling nor use any typing magic; stack overflow is not likely. I
> humbly ask this list about means to improve valgrind or gdb outputs, which
> don't report informative function names, or more generally, any tip that
> could help me to locate the origin of the problem.
>
> You should try to compile the OCaml runtime in debug mode: just "make
> ocamlrund"
> in the ...ocaml/bytecode directory, then run your program with ocamlrund.
>
> > 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 ?
>
> The default space_overhead is already 80.  If you want the major GC
> to run very slowly, set the overhead to 1000 or 10000.  But usually
> you want to do the opposite, so that the crash happens soon after the
> execution of the buggy code.  You can try to pepper your code with
> calls to Gc.compact, for example.  In your case, I would call it just
> before the pattern matching that crashes mysteriously.
>
> -- Damien
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>

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

  reply	other threads:[~2010-12-05 14:50 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1182061596.483210.1291158525016.JavaMail.root@zmbs1.inria.fr>
2010-12-03 15:43 ` Damien Doligez
2010-12-05 14:50   ` Philippe Veber [this message]
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
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

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='AANLkTimUSh8YMyxcJM3XpKDfF3f78dhaUGd14ofmA=De@mail.gmail.com' \
    --to=philippe.veber@googlemail.com \
    --cc=caml-list@inria.fr \
    --cc=damien.doligez@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).