[llvm-bugs] [Bug 31008] New: OCaml binding memory crash
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Nov 13 22:21:44 PST 2016
https://llvm.org/bugs/show_bug.cgi?id=31008
Bug ID: 31008
Summary: OCaml binding memory crash
Product: new-bugs
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: youngju.song at sf.snu.ac.kr
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
According to the manual
(https://caml.inria.fr/pub/docs/manual-ocaml/intfc.html)'s Rule 5, block must
be filled by direct assignment after "caml_alloc_small".
```
Rule 5 After a structured block (a block with tag less than No_scan_tag) is
allocated with the low-level functions, all fields of this block must be filled
with well-formed values before the next allocation operation. If the block has
been allocated with caml_alloc_small, filling is performed by direct assignment
to the fields of the block:
Field(v, n) = vn;
```
However, in the code below, there does not exist such assignment.
https://github.com/llvm-mirror/llvm/blob/master/bindings/ocaml
/llvm/llvm_ocaml.c#L483
https://github.com/llvm-mirror/llvm/blob/master/bindings/ocaml/llvm/llvm_ocaml.c#L630
This actually led to memory crash, and following patch solved it.
```
result = caml_alloc_small(1, 0);
+ Field(result,0) = Val_int(0);
Store_field(result, 0, caml_copy_string(C));
```
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20161114/d3050d2a/attachment.html>
More information about the llvm-bugs
mailing list