Targeted Static Analysis for OCaml C Stubs: eliminating gremlins from the code

07/27/2023
by   Edwin Török, et al.
0

Migration to OCaml 5 requires updating a lot of C bindings due to the removal of naked pointer support. Writing OCaml user-defined primitives in C is a necessity, but is unsafe and error-prone. It does not benefit from either OCaml's or C's type checking, and existing C static analysers are not aware of the OCaml GC safety rules, and cannot infer them from existing macros alone.The alternative is automatically generating C stubs, which requires correctly managing value lifetimes. Having a static analyser for OCaml to C interfaces is useful outside the OCaml 5 porting effort too. After some motivating examples of real bugs in C bindings a static analyser is presented that finds these known classes of bugs. The tool works on the OCaml abstract parse and typed trees, and generates a header file and a caller model. Together with a simplified model of the OCaml runtime this is used as input to a static analysis framework, Goblint. An analysis is developed that tracks dereferences of OCaml values, and together with the existing framework reports incorrect dereferences. An example is shown how to extend the analysis to cover more safety properties. The tools and runtime models are generic and could be reused with other static analysis tools.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
04/10/2023

QChecker: Detecting Bugs in Quantum Programs via Static Analysis

Static analysis is the process of analyzing software code without execut...
research
04/20/2023

Leveraging Static Analysis for Bug Repair

We propose a method combining machine learning with a static analysis to...
research
04/21/2021

Assessing Validity of Static Analysis Warnings using Ensemble Learning

Static Analysis (SA) tools are used to identify potential weaknesses in ...
research
07/04/2019

Integration of the Static Analysis Results Interchange Format in CogniCrypt

Background - Software companies increasingly rely on static analysis too...
research
03/06/2018

DexLego: Reassembleable Bytecode Extraction for Aiding Static Analysis

The scale of Android applications in the market is growing rapidly. To e...
research
03/02/2021

The High-Assurance ROS Framework

This tool paper presents the High-Assurance ROS (HAROS) framework. HAROS...
research
02/24/2022

Deploying Static Analysis

Static source code analysis is a powerful tool for finding and fixing bu...

Please sign up or login with your details

Forgot password? Click here to reset