skip to main content
10.1145/2970276.2970310acmconferencesArticle/Chapter ViewAbstractPublication PagesaseConference Proceedingsconference-collections
research-article
Public Access

Array length inference for C library bindings

Published: 25 August 2016 Publication History

Abstract

Simultaneous use of multiple programming languages (polyglot programming) assists in creating efficient, coherent, modern programs in the face of legacy code. However, manually creating bindings to low-level languages like C is tedious and error-prone. We offer relief in the form of an automated suite of analyses, designed to enhance the quality of automatically produced bindings. These analyses recover high-level array length information that is missing from C’s type system. We emit annotations in the style of GObject-Introspection, which produces bindings from annotations on function signatures. We annotate each array argument as terminated by a special sentinel value, fixed-length, or of length determined by another argument. These properties help produce more idiomatic, efficient bindings. We correctly annotate at least 70% of all arrays with these length types, and our results are comparable to those produced by human annotators, but take far less time to produce.

References

[1]
P. Alves, F. Gruber, J. Doerfert, A. Lamprineas, T. Grosser, F. Rastello, and F. M. Q. a. Pereira. Runtime pointer disambiguation. In Proceedings of the 2015 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2015, pages 589–606, New York, NY, USA, 2015. ACM.
[2]
D. M. Beazley. Swig: An easy to use tool for integrating scripting languages with c and c++. In Proceedings of the 4th Conference on USENIX Tcl/Tk Workshop, 1996 - Volume 4, TCLTK’96, pages 15–15, Berkeley, CA, USA, 1996. USENIX Association.
[3]
D. Dhurjati, S. Kowshik, V. Adve, and C. Lattner. Memory safety without runtime checks or garbage collection. In Proceedings of the 2003 ACM SIGPLAN Conference on Language, Compiler, and Tool for Embedded Systems, LCTES ’03, pages 69–80, New York, NY, USA, 2003. ACM.
[4]
M. Furr and J. S. Foster. Checking type safety of foreign function calls. ACM Trans. Program. Lang. Syst., 30(4): 18:1–18:63, Aug. 2008.
[5]
The GNOME Project. GNOME, Nov. 2015.
[6]
The GNOME Project. Gck library reference manual, Oct. 2015.
[7]
The GNOME Project. GIO reference manual, Nov. 2015.
[8]
The GNOME Project. GLib reference manual, Nov. 2015.
[9]
The GNOME Project. GObject-Introspection Annotations, June 2015.
[10]
S. Golemon, M. Gusarov, The Written Word, Inc., E. Fant, D. Stenberg, and S. Josefsson. libssh2, Oct. 2015.
[11]
B. Hackett, M. Das, D. Wang, and Z. Yang. Modular checking for buffer overflows in the large. In Proceedings of the 28th International Conference on Software Engineering, ICSE ’06, pages 232–241, New York, NY, USA, 2006. ACM.
[12]
C. Lattner and V. Adve. LLVM: A compilation framework for lifelong program analysis & transformation. In Proceedings of the International Symposium on Code Generation and Optimization: Feedback-directed and Runtime Optimization, CGO ’04, pages 75–, Washington, DC, USA, 2004. IEEE Computer Society.
[13]
W. Le and M. L. Soffa. Refining buffer overflow detection via demand-driven path-sensitive analysis. In Proceedings of the 7th ACM SIGPLAN-SIGSOFT Workshop on Program Analysis for Software Tools and Engineering, PASTE ’07, pages 63–68, New York, NY, USA, 2007. ACM.
[14]
The libgit2 contributors. libgit2, Oct. 2015.
[15]
S. Lu, S. Park, C. Hu, X. Ma, W. Jiang, Z. Li, R. A. Popa, and Y. Zhou. Muvi: Automatically inferring multi-variable access correlations and detecting related semantic and concurrency bugs. SIGOPS Oper. Syst. Rev., 41(6):103–116, Oct. 2007.
[16]
S. Nagarakatte, J. Zhao, M. M. Martin, and S. Zdancewic. SoftBound: Highly compatible and complete spatial memory safety for C. In Proceedings of the 30th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI ’09, pages 245–258, New York, NY, USA, 2009. ACM.
[17]
H. Nazaré, I. Maffra, W. Santos, L. Barbosa, L. Gonnord, and F. M. Quintão Pereira. Validation of memory accesses through symbolic analyses. SIGPLAN Not., 49(10):791–809, Oct. 2014.
[18]
G. C. Necula, J. Condit, M. Harren, S. McPeak, and W. Weimer. CCured: Type-safe retrofitting of legacy software. ACM Trans. Program. Lang. Syst., 27(3):477–526, May 2005.
[20]
T. Ravitch and B. Liblit. Analyzing memory ownership patterns in C libraries. In P. Cheng and E. Petrank, editors, International Symposium on Memory Management, ISMM ’13, Seattle, WA, USA - June 20 - 20, 2013, pages 97–108. ACM, 2013.
[21]
T. Ravitch, S. Jackson, E. Aderhold, and B. Liblit. Automatic generation of library bindings using static analysis. In M. Hind and A. Diwan, editors, Proceedings of the 2009 ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2009, Dublin, Ireland, June 15-21, 2009, pages 352–362. ACM, 2009.
[22]
R. Rugina and M. C. Rinard. Symbolic bounds analysis of pointers, array indices, and accessed memory regions. ACM Trans. Program. Lang. Syst., 27(2):185–235, Mar. 2005.
[23]
The Telepathy Project. telepathy, Aug. 2014.
[24]
D. A. Wheeler. SLOCCount, June 2015.
[25]
T. Wies, V. Kuncak, K. Zee, A. Podelski, M. Rinard, T. Wies, V. Kuncak, K. Zee, A. Podelski, and M. Rinard. Verifying complex properties using symbolic shape analysis. In In Workshop on heap abstraction and verification, 2007.

Cited By

View all
  • (2023)Analyzing C++ Stream Parallelism in Shared-Memory when Porting to Flink and Storm2023 International Symposium on Computer Architecture and High Performance Computing Workshops (SBAC-PADW)10.1109/SBAC-PADW60351.2023.00017(46-53)Online publication date: 17-Oct-2023
  • (2022)Bind the gap: compiling real software to hardware FFT acceleratorsProceedings of the 43rd ACM SIGPLAN International Conference on Programming Language Design and Implementation10.1145/3519939.3523439(687-702)Online publication date: 9-Jun-2022
  • (2017)The Computer for the 21st Century: Security & Privacy Challenges after 25 Years2017 26th International Conference on Computer Communication and Networks (ICCCN)10.1109/ICCCN.2017.8038394(1-10)Online publication date: Jul-2017

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
ASE '16: Proceedings of the 31st IEEE/ACM International Conference on Automated Software Engineering
August 2016
899 pages
ISBN:9781450338455
DOI:10.1145/2970276
  • General Chair:
  • David Lo,
  • Program Chairs:
  • Sven Apel,
  • Sarfraz Khurshid
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 25 August 2016

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. FFI
  2. bindings
  3. foreign function interfaces
  4. libraries
  5. static analysis
  6. type inference

Qualifiers

  • Research-article

Funding Sources

Conference

ASE'16
Sponsor:

Acceptance Rates

Overall Acceptance Rate 82 of 337 submissions, 24%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)69
  • Downloads (Last 6 weeks)15
Reflects downloads up to 13 Feb 2025

Other Metrics

Citations

Cited By

View all
  • (2023)Analyzing C++ Stream Parallelism in Shared-Memory when Porting to Flink and Storm2023 International Symposium on Computer Architecture and High Performance Computing Workshops (SBAC-PADW)10.1109/SBAC-PADW60351.2023.00017(46-53)Online publication date: 17-Oct-2023
  • (2022)Bind the gap: compiling real software to hardware FFT acceleratorsProceedings of the 43rd ACM SIGPLAN International Conference on Programming Language Design and Implementation10.1145/3519939.3523439(687-702)Online publication date: 9-Jun-2022
  • (2017)The Computer for the 21st Century: Security & Privacy Challenges after 25 Years2017 26th International Conference on Computer Communication and Networks (ICCCN)10.1109/ICCCN.2017.8038394(1-10)Online publication date: Jul-2017

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Login options

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media