caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alexey Egorov <alex.only.d@gmail.com>
To: David Allsopp <dra-news@metastack.com>
Cc: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] memory corruption using C stub
Date: Sun, 11 Jun 2017 20:26:33 +0500	[thread overview]
Message-ID: <CAJannG5KS-rRivfE0SO7gpkDHN9Sg8CMxHcyXGbkftFwDRgh=g@mail.gmail.com> (raw)
In-Reply-To: <69699CC5-7EF4-42FF-92DB-C065F412963C@metastack.com>

> Are there other packages you are using which themselves have C stubs?
No, except maybe stubs in Array and Unix modules (we are using lots of
Unix.create_process and related functions).
You are right, our C stub is correct - I increased a load on
application and it crashes even without calling this C function...

> I presume you're seeing the crash from all versions? Are you able to do a 4.02.3 test, or is that impractical?
Yes, app crashes in all versions. I tried 4.02.3 - still crashing :(


2017-06-11 17:07 GMT+05:00 David Allsopp <dra-news@metastack.com>:
> On 11 Jun 2017, at 12:54, Alexey Egorov <alex.only.d@gmail.com> wrote:
>>
>> OCaml side is a complex server-side application; unfortunately, it's
>> closed-source and when I'm trying to minimize OCaml side too it stops
>> crashing...
>
> Ah well! Are there other packages you are using which themselves have C stubs? If minimising the OCaml application is also eliminating the problem, then it could be that it's just the allocations in your (correct) C stub which are revealing the crash elsewhere. Unfortunately, incorrect C stub can include OCaml unix functions...
>
> Spattering Gc.full_major on the OCaml can help try to find corruptions earlier - have you tried that too?
>
>> I'm using fdopen's opam repository
>> (https://github.com/fdopen/opam-repository-mingw) with compiler's
>> versions from 4.03 to 4.05-beta3.
>
> I presume you're seeing the crash from all versions? Are you able to do a 4.02.3 test, or is that impractical?
>
>
> David
>
>
>> 2017-06-11 16:45 GMT+05:00 David Allsopp <dra-news@metastack.com>:
>>>> On 11 Jun 2017, at 12:38, Alexey Egorov <alex.only.d@gmail.com> wrote:
>>>>
>>>> OK, I'm minimized this function as much as possible and it's still
>>>> crashing - https://pastebin.com/MZ0Qkh9B
>>>> Now I'm thinking that is compiler's bug on windows...
>>>
>>> Are you able to post the OCaml side of your minimised code? Which port of OCaml are you using?
>>>
>>>
>>> David
>>>
>>>
>>>> 2017-06-10 20:33 GMT+05:00 Alexey Egorov <alex.only.d@gmail.com>:
>>>>> Hello,
>>>>>
>>>>> I have an OCaml application with some C code which (I believe) is the
>>>>> reason of some random crashes.
>>>>>
>>>>> Here is the code - https://pastebin.com/FVtLphZu
>>>>> This function reads file at given offset, divides data into chunks and
>>>>> compute checksums and compression ratio:
>>>>> external compute_data_props
>>>>>   : string -> int -> int -> int -> (int * int * float) list =
>>>>> "compute_data_props"
>>>>>
>>>>> The problem is, after some calls to this stub, application is crashing
>>>>> at random places in OCaml code.
>>>>> I can't figure out what's going wrong, but replacing this stub with
>>>>> dummy function (which does nothing but returns some predefined list)
>>>>> eliminates the problem.
>>>>>
>>>>> What can we do to debug it? We are using OCaml 4.04.1 and Windows 10,
>>>>> and there is no other C stubs in our codebase.
>>>>>
>>>>> Thanks!
>>>>
>>>> --
>>>> 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

  reply	other threads:[~2017-06-11 15:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-10 15:33 Alexey Egorov
2017-06-10 15:40 ` Viet Le
2017-06-10 17:00   ` Alexey Egorov
2017-06-10 15:44 ` Daniel Bünzli
2017-06-10 15:50   ` Daniel Bünzli
2017-06-10 16:01   ` Daniel Bünzli
2017-06-11 11:37 ` Alexey Egorov
2017-06-11 11:45   ` David Allsopp
2017-06-11 11:54     ` Alexey Egorov
2017-06-11 12:07       ` David Allsopp
2017-06-11 15:26         ` Alexey Egorov [this message]
2017-06-11 18:49 ` Alexey Egorov
2017-06-11 19:20   ` David Allsopp

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='CAJannG5KS-rRivfE0SO7gpkDHN9Sg8CMxHcyXGbkftFwDRgh=g@mail.gmail.com' \
    --to=alex.only.d@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=dra-news@metastack.com \
    /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).