|
ABSTRACT
We present a multi-lingual type inference system for checking type safety across a foreign function interface. The goal of our system is to prevent foreign function calls from introducing type and memory safety violations into an otherwise safe language. Our system targets OCaml's FFI to C, which is relatively lightweight and illustrates some interesting challenges in multi-lingual type inference. The type language in our system embeds OCaml types in C types and vice-versa, which allows us to track type information accurately even through the foreign language, where the original types are lost. Our system uses representational types that can model multiple OCaml types, because C programs can observe that many OCaml types have the same physical representation. Furthermore, because C has a low-level view of OCaml data, our inference system includes a dataflow analysis to track memory offsets and tag information. Finally, our type system includes garbage collection information to ensure that pointers from the FFI to the OCaml heap are tracked properly. We have implemented our inference system and applied it to a small set of benchmarks. Our results show that programmers do misuse these interfaces, and our implementation has found several bugs and questionable coding practices in our benchmarks.
REFERENCES
Note: OCR errors may be found in this Reference List extracted from the full text article. ACM has opted to expose the complete List rather than only correct and linked references.
| |
1
|
ANSI. Programming languages -- C, 1999. ISO/IEC 9899:1999.
|
| |
2
|
D. M. Beazley. SWIG: An easy to use tool for integrating scripting languages with C and C++,.
|
| |
3
|
N. Benton and A. Kennedy, editors. BABEL'01: First International Workshop on Multi-Language Infrastructure and Interoperability, volume 59 of Electronic Notes in Theoretical Computer Science, Firenze, Italy, Sept. 2001. http://www.elsevier.nl/locate/entcs/volume59.html.
|
| |
4
|
M. Blume. No-Longer-Foreign: Teaching an ML compiler to speak C "natively". In Benton and Kennedy babel01. http://www.elsevier.nl/locate/entcs/volume59.html.
|
 |
5
|
|
| |
6
|
A. S. Christensen, A. Møller, and M. I. Schwartzbach. Precise Analysis of String Expressions. In R. Cousot, editor, Static Analysis, 10th International Symposium, volume 2694 of Lecture Notes in Computer Science, pages 1--18, San Diego, CA, USA, June 2003. Springer-Verlag.
|
| |
7
|
R. DeLine and M. Fähndrich. The Fugue Protocol Checker: Is your software Baroque? Technical Report MSR-TR-2004-07, Microsoft Research, Jan. 2004.
|
 |
8
|
Sigbjorn Finne , Daan Leijen , Erik Meijer , Simon Peyton Jones, Calling hell from heaven and heaven from hell, Proceedings of the fourth ACM SIGPLAN international conference on Functional programming, p.114-125, September 27-29, 1999, Paris, France
|
| |
9
|
K. Fisher, R. Pucella, and J. Reppy. A framework for interoperability. In Benton and Kennedy {3}. http://www.elsevier.nl/locate/entcs/volume59.html.
|
| |
10
|
M. Furr and J. S. Foster. Checking Type Safety of Foreign Function Calls. Technical Report CS-TR-4627, University of Maryland, Computer Science Department, Nov. 2004.
|
| |
11
|
|
 |
12
|
|
| |
13
|
J. Hamilton. Interlanguage Object Sharing with SOM. In Proceedings of the Usenix 1996 Annual Technical Conference, San Diego, California, Jan. 1996.
|
 |
14
|
|
| |
15
|
L. Huelsbergen. A Portable C Interface for Standard ML of New Jersey. http://www.smlnj.org//doc/SMLNJ-C/smlnj-c.ps, 1996.
|
| |
16
|
X. Leroy. The Objective Caml system, Aug. 2004. Release 3.08, http://caml.inria.fr/distrib/ocaml-3.08/ocaml-3.08-refman.pdf.
|
| |
17
|
|
| |
18
|
|
 |
19
|
|
| |
20
|
|
 |
21
|
|
| |
22
|
|
CITED BY 11
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Jeffrey S. Foster , Michael W. Hicks , William Pugh, Improving software quality with static analysis, Proceedings of the 7th ACM SIGPLAN-SIGSOFT workshop on Program analysis for software tools and engineering, p.83-84, June 13-14, 2007, San Diego, California, USA
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|