<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Aug 8, 2016 at 8:46 PM, Mikhail Glushenkov <span dir="ltr"><<a href="mailto:mikhail.glushenkov@gmail.com" target="_blank">mikhail.<wbr>glushenkov@gmail.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Yes, this can be done with JNI, see e.g. [1]. Additionally, by using<br>sun.misc.Unsafe [2], one can cause segfaults even from pure Java.<br>[1] <a href="https://www.cs.princeton.edu/~appel/papers/safejni.pdf" rel="noreferrer" target="_blank">https://www.cs.princeton.<wbr>edu/~appel/papers/safejni.pdf</a><br>[2] <a href="http://www.inf.usi.ch/faculty/lanza/Downloads/Mast2015a.pdf" rel="noreferrer" target="_blank">http://www.inf.usi.ch/<wbr>faculty/lanza/Downloads/<wbr>Mast2015a.pdf</a></blockquote></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">Ah, I see. I thought that, ruling out FFI, that you couldn't segfault with pure Java code.  Good to know about the unsafe interface.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 8, 2016 at 7:32 PM, David Terei <span dir="ltr"><<a href="mailto:davidterei@gmail.com" target="_blank">davidterei@gmail.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
If you have the energy, it'd be great to put some of this thinking<br>
into a wiki page (<a href="https://ghc.haskell.org/trac/ghc/wiki/SafeHaskell" rel="noreferrer" target="_blank">https://ghc.haskell.org/trac/<wbr>ghc/wiki/SafeHaskell</a>)<br>
and flesh out a first approximation of what IO API's cause issues. Is<br>
it just Ptr not carrying bounds around with it? Maybe, but then we<br>
need to secure how Ptr's can be created, which excludes FFI returning<br>
Ptr's.<br></blockquote><div><br></div><div>Yes, we can add a Wiki page.</div><div><br></div><div>Btw I was thinking more of kicking FFI/peek/poke outside of the Safe bubble, not changing their operational behavior.  First of all, it's nigh impossible to lock down FFI calls.</div><div><br></div><div>When someone, <a href="https://existentialtype.wordpress.com/2012/08/14/haskell-is-exceptionally-unsafe/" target="_blank">e.g. Bob Harper</a>, points out a problem in Haskell, we sometimes respond "hey, <i>Safe Haskell</i> is the real objet d'art!  It's a safe language."  Yet it isn't really a full <i>language</i> if people cannot write and run programs in it!  (Because every program must be ultimately be `main::IO()`.)  Kicking out segfaulty features would still leave a safe language that people can write complete programs in.</div><div><br></div><div>Best,</div><div>  -Ryan</div><div><br></div><div><br></div></div></div></div>