From a156efdf71bc668093e31593713694cf076db895 Mon Sep 17 00:00:00 2001 From: Torok Edwin Date: Thu, 23 Dec 2010 15:49:26 +0000 Subject: Fix OCaml bindings crash, PR8847. See http://caml.inria.fr/mantis/view.php?id=4166 If we call only external functions from a module, then its 'let _' bindings don't get executed, which means that the exceptions don't get registered for use in the C code. This in turn causes llvm_raise to call raise_with_arg() with a NULL pointer and cause a segmentation fault. The workaround is to declare all 'external' functions as 'val' in these .mli files. Also added a separate testcase (the testcase must call only external functions for the bug to occur). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122497 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Bindings/Ocaml/ext_exc.ml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 test/Bindings/Ocaml/ext_exc.ml (limited to 'test/Bindings') diff --git a/test/Bindings/Ocaml/ext_exc.ml b/test/Bindings/Ocaml/ext_exc.ml new file mode 100644 index 0000000..7954351 --- /dev/null +++ b/test/Bindings/Ocaml/ext_exc.ml @@ -0,0 +1,16 @@ +(* RUN: %ocamlopt -warn-error A llvm.cmxa llvm_bitreader.cmxa llvm_executionengine.cmxa %s -o %t + * RUN: %t ();; +let _ = + try + ignore (Llvm.MemoryBuffer.of_file "/path/to/nonexistent/file") + with + Llvm.IoError _ -> ();; -- cgit v1.1