From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by c5ff346549e7 (Postfix) with ESMTP id 7958D5D5 for ; Sat, 5 May 2018 03:26:31 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.49,364,1520895600"; d="scan'208,217";a="325843886" Received: from sympa.inria.fr ([193.51.193.213]) by mail2-relais-roc.national.inria.fr with ESMTP; 05 May 2018 05:26:30 +0200 Received: by sympa.inria.fr (Postfix, from userid 20132) id 6FA4D8244F; Sat, 5 May 2018 05:26:30 +0200 (CEST) Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id AAC868240C for ; Sat, 5 May 2018 05:26:20 +0200 (CEST) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=murthy.chet@gmail.com; spf=Pass smtp.mailfrom=murthy.chet@gmail.com; spf=None smtp.helo=postmaster@mail-vk0-f48.google.com IronPort-PHdr: =?us-ascii?q?9a23=3AHGUeXx9bmxg+Pf9uRHKM819IXTAuvvDOBiVQ1KB3?= =?us-ascii?q?1+McTK2v8tzYMVDF4r011RmVBd6ds6oMotGVmpioYXYH75eFvSJKW713fDhBt/?= =?us-ascii?q?8rmRc9CtWOE0zxIa2iRSU7GMNfSA0tpCnjYgBaF8nkelLdvGC54yIMFRXjLwp1?= =?us-ascii?q?Ifn+FpLPg8it2O2+55Pebx9UiDahfLh/MAi4oQLNu8cMnIBsMLwxyhzHontJf+?= =?us-ascii?q?RZ22ZlLk+Nkhj/+8m94odt/zxftPw9+cFAV776f7kjQrxDEDsmKWE169b1uhTF?= =?us-ascii?q?UACC+2ETUmQSkhpPHgjF8BT3VYr/vyfmquZw3jSRMNboRr4oRzut86ZrSAfpiC?= =?us-ascii?q?gZMT457HrXgdF0gK5CvR6tuwBzz4vSbY6SKfR+Y7jdfcsESmVdQsZfWStBAoam?= =?us-ascii?q?YIsOCeoKIOJUoob5qlcLqxa1GAuiC/71yjJQhHD206003eoiHw/bwgIvA8kDv2?= =?us-ascii?q?7IoNjvLqoeTfy5wavOwD7eb/1WwzD96I3Qfx0/ofGDQ65wetfWx0kyDQPFklWQ?= =?us-ascii?q?qIz4ND6S0+QNrnKb7/ZgVeOvkWIotwFxrSazxso3hYnJg5gaylHA9Slj3Ik1It?= =?us-ascii?q?i4RVd9bNW5HpVQsCSaOJF3QsMkW2xouSA6yqcHuZGhZiQKxo4nywbfavOdc4iI?= =?us-ascii?q?5RXjWPyNLjd/gXJofq+0iRWq8UW41OHwSs253ExJoydFiNXAqG0B2hLJ5sWISf?= =?us-ascii?q?Zw+Fqq1yyV2ADJ8O5EJFg5larFJJ4lxb49jp8Tvl7CHi/ygUn2kqyWelk99uim?= =?us-ascii?q?5OnqYa/qppCbN49zhQH+NrohltajDuQ/NwgCR2mb+eKi273/5UD1XqlGg/ksnq?= =?us-ascii?q?TasJ3WP9oXqrO3DgNP3Ysu6A6zDzK839QZmXkHIkhFeBWCj4XxPlHOPer4Deu/?= =?us-ascii?q?g1Wsijtk2/DGMaP9ApjWIXjDla3ufbd560JG1AUzytVf64pOCr4dOPLzRlPxtN?= =?us-ascii?q?vAAxAlKQO0xuLnBMx51oMfQmKPHrSUMLjSsF+N/uIgOfOAZI4TuDbnKvgq/eTi?= =?us-ascii?q?jXEjmQxVQa7884EaZH2iH/8uG0iDe3vrnp9VH38HpBA/S/DCh1iLUDoVbHG3Cf?= =?us-ascii?q?ES/DY+XammAJuLY523nLyQlHO+A4dKZnEAAVCBDV/ncoyFX7EHbyfEcZwpqSAN?= =?us-ascii?q?SbX0E9xp7hqprgKvjuc+d7uGymgjrZvmkeNNyajWnBA2+yZzCp3EgW6IRmBw2G?= =?us-ascii?q?gPQm1vhfwtkQlG0l6GlJNArblAD9UKvqFGVw47MdjXyOkoU4mvCDKERc+ATROd?= =?us-ascii?q?evvjATw1SYhskdoHYkI4Bdb6yx6fj2ylBLgak7HND5sxoPrR?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0AvAgClI+1ahjDVVdFcGwEBAQEDAQEBC?= =?us-ascii?q?QEBAYNoATwXYxUTCoMlP4EdglCRCIF5gQ+BQIxuhmoLI4RJAoIxBxkHAQQ0FAE?= =?us-ascii?q?CAQEBAQEBAQEBEwEBAQgLCwgoIwyCNSSCUAECAgEMFx0BGxILAQMBCwYDAgQHA?= =?us-ascii?q?xcdAgIhAQERAQUBChIGExKEaQEDDQgPjSOQADyLBYF/BQEXgnAFg1IKGSYDClR?= =?us-ascii?q?XgjACBhKIE4ITgQ+DC4JPN4Enc4JTglQChg4IgQOFWop/LAiFZYVrZ4IWXYEUi?= =?us-ascii?q?myJQkmGLg8DHoEEDCeBczMaI1AxghIJgWckGoNOgT6JNB8wjXqCNwEB?= X-IPAS-Result: =?us-ascii?q?A0AvAgClI+1ahjDVVdFcGwEBAQEDAQEBCQEBAYNoATwXYxU?= =?us-ascii?q?TCoMlP4EdglCRCIF5gQ+BQIxuhmoLI4RJAoIxBxkHAQQ0FAECAQEBAQEBAQEBE?= =?us-ascii?q?wEBAQgLCwgoIwyCNSSCUAECAgEMFx0BGxILAQMBCwYDAgQHAxcdAgIhAQERAQU?= =?us-ascii?q?BChIGExKEaQEDDQgPjSOQADyLBYF/BQEXgnAFg1IKGSYDClRXgjACBhKIE4ITg?= =?us-ascii?q?Q+DC4JPN4Enc4JTglQChg4IgQOFWop/LAiFZYVrZ4IWXYEUimyJQkmGLg8DHoE?= =?us-ascii?q?EDCeBczMaI1AxghIJgWckGoNOgT6JNB8wjXqCNwEB?= X-IronPort-AV: E=Sophos;i="5.49,364,1520895600"; d="scan'208,217";a="325843793" Received: from mail-vk0-f48.google.com ([209.85.213.48]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 05 May 2018 05:26:19 +0200 Received: by mail-vk0-f48.google.com with SMTP id 10-v6so14529641vkh.5 for ; Fri, 04 May 2018 20:26:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=IWpf8jGff9H/7cGe/2J3lrHZvwWPekO6i951gVKHKXI=; b=Gul0XjYxGSt34WTE8AThE5bbDSVyqlVYBWFsEOaAt717WMy08szMPE0k1fOEjDrPw4 Rvd0zDRSt24G211CMJuod0WcLDS0gj1tfax6yMWL6bkgwzHKc46yVu4/MmXvI6HUJBwJ MQWYYd6hgfGgKFYmMzwr+JlAk6ye0gLijhmu24iaW7PV7qhlfQ6ojly4Oy9bez8xFgJN Z79mPdHbygpfiF2aQB8T758s5PmmetLEh6cXI7fnOWPYcU2O3ZxwY+aWLGdGUr6XQ2mN iDzRJuiSM/O1UGc0zihoWekKz1JXRiOJLJAWPTW49h0zSJ3IT23W/JKJBCVBUeN0eEwr uMHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=IWpf8jGff9H/7cGe/2J3lrHZvwWPekO6i951gVKHKXI=; b=OzavaK6L82uaWv/822bQJXUD+mS0vhZ7XknDgvA56rXovpuZacEJwJFAzxhSnxEbJQ C74MzXC4kRu6wRGbYKDfhDS6fMK0npePeCM/1MZogZs1E2sr8c3/4Gw6YCOBZwxyxHmY MVW2h1OC06Pseo1pMkHRHHAAvvEZ9hW/8tr7/KT5uJ4eFxBJvt6XY+YAlptEM3UUyFn+ WiBMrpz1Y9lt4JCMzkeh5gIffriCrma6Zp1X58MCdn0k5zaWX9FZy/InGXcW9z7leor2 TMoCOiZCZ19rrsM7+WYtcXyEkv2LKntZv7/IhZjSTw1N6bx5xsf9znOFN7cpvCZYjcwm +Fqg== X-Gm-Message-State: ALQs6tA/sRc8tAi6MLIofhEdFApD1NWM2GU/WJiLPvsAIury08c4e2Au xsMqI0PMPxsCpkmEOQBe2IpR2n5Aqh8EFOeLs28= X-Google-Smtp-Source: AB8JxZoAro+ILEzuDOhBrWq3Mwrlj94FYT/m7lLYCdhnpu/8/Ef9VEc8eFtSf6tMz/lS7EbPU+Ane8jufN6/hly91us= X-Received: by 2002:a1f:bf17:: with SMTP id p23-v6mr26017447vkf.73.1525490778168; Fri, 04 May 2018 20:26:18 -0700 (PDT) MIME-Version: 1.0 Received: by 10.176.97.134 with HTTP; Fri, 4 May 2018 20:26:17 -0700 (PDT) In-Reply-To: References: From: Chet Murthy Date: Fri, 4 May 2018 20:26:17 -0700 Message-ID: To: Frederic Perriot Cc: caml-list Content-Type: multipart/alternative; boundary="000000000000f0e212056b6cffc3" Subject: Re: [Caml-list] a bad value detector Reply-To: Chet Murthy X-Loop: caml-list@inria.fr X-Sequence: 16874 Errors-to: caml-list-owner@inria.fr Precedence: list Precedence: bulk Sender: caml-list-request@inria.fr X-no-archive: yes List-Id: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --000000000000f0e212056b6cffc3 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable If I remember correctly, a company once started with Boehm's conservative GC, and by doing things somewhat like you suggest, built a memory-leak-detector product. So you're not alone in going down this sort of path. On Wed, May 2, 2018 at 9:19 AM, Frederic Perriot wrote: > Hello caml-list, > > I'd like to propose a detector to help in the detection of incorrect C > bindings that do not follow the GC rules. > > The idea is rather simple: > > 1. after a minor collection, mprotect the pages of the minor heap to > disallow reads and writes > 2. install a SEGV handler to catch the ensuing faults > 3. if the faulting address is above caml_young_ptr - Max_young_whsize, > unprotect the page and carry on > 4. otherwise, the program has no business accessing a value in the > unallocated part of the minor heap, so let it crash > > I've hacked up a prototype that protects a single page at > caml_young_start, and it catches the bug I mention in my other message > entitled "an implicit GC rule". > > Such a change surely degrades performance, but maybe it would be > useful as a runtime option available through CAMLRUNPARAM, to detect > misbehaved C bindings. > > Does it sound like a viable technique? > > I'm curious to hear what you think. > > thanks, > Fr=C3=A9d=C3=A9ric Perriot > > -- > 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 --=20 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= --000000000000f0e212056b6cffc3 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
If I remember correctly, a company once started with Boehm= 's conservative GC, and by doing things somewhat like you suggest, buil= t a memory-leak-detector product.=C2=A0 So you're not alone in going do= wn this sort of path.

On Wed, May 2, 2018 at 9:19 AM, Frederic Perriot <fperriot@gmai= l.com> wrote:
Hello caml-li= st,

I'd like to propose a detector to help in the detection of incorrect C<= br> bindings that do not follow the GC rules.

The idea is rather simple:

1. after a minor collection, mprotect the pages of the minor heap to
disallow reads and writes
2. install a SEGV handler to catch the ensuing faults
3. if the faulting address is above caml_young_ptr - Max_young_whsize,
unprotect the page and carry on
4. otherwise, the program has no business accessing a value in the
unallocated part of the minor heap, so let it crash

I've hacked up a prototype that protects a single page at
caml_young_start, and it catches the bug I mention in my other message
entitled "an implicit GC rule".

Such a change surely degrades performance, but maybe it would be
useful as a runtime option available through CAMLRUNPARAM, to detect
misbehaved C bindings.

Does it sound like a viable technique?

I'm curious to hear what you think.

thanks,
Fr=C3=A9d=C3=A9ric Perriot

--
Caml-list mailing list.=C2=A0 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

--000000000000f0e212056b6cffc3--