caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] a bad value detector
@ 2018-05-02 16:19 Frederic Perriot
  2018-05-04 20:48 ` Perry E. Metzger
  2018-05-05  3:26 ` Chet Murthy
  0 siblings, 2 replies; 6+ messages in thread
From: Frederic Perriot @ 2018-05-02 16:19 UTC (permalink / raw)
  To: caml-list

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édéric 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-05-12 10:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-02 16:19 [Caml-list] a bad value detector Frederic Perriot
2018-05-04 20:48 ` Perry E. Metzger
2018-05-09  8:39   ` Frederic Perriot
2018-05-11  5:54     ` Stijn Devriendt
2018-05-12 10:54       ` Frederic Perriot
2018-05-05  3:26 ` Chet Murthy

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).