arXiv · 2611.37595
A View from the Bridge: Detecting Boundary Type Errors in Native Extensions of Dynamic Languages
Abstract
Programs written in dynamic languages, such as Python and JavaScript, often rely on native extensions written in C, C++ or Rust for performance or access to system libraries. Native code accesses the raw memory of the values it receives from the host, so before using a value, it must check the value's tag, which determines its memory layout. When this check is missing, or accepts tags incompatible with the one that the native code later assumes, a boundary type error occurs, and the program crashes or silently corrupts its data. Our key insight is that finding these errors requires no inference of host-language types. Native code must check every value it obtains from the host, so the code itself provides all the information we need: its checks indicate which tags a value may have, while its operations reveal which tag they assume. We capture what native code does with host values in XLIR, a small language in which we define boundary type errors. We then detect them with a flow-sensitive analysis that tracks the tags each check establishes. At each operation, we encode whether some value can pass the preceding checks yet violate the tag that the operation assumes as a satisfiability problem, which we solve with an SMT solver. We have implemented our approach in a tool called Xtypecheck, which analyzes the LLVM IR of Node.js and CPython extensions. It detects all 72 known errors in an existing JavaScript benchmark and 33 of 42 reported in fixed GitHub issues of popular PyPI packages. In the wild, Xtypecheck finds thousands of previously unknown type errors in the native code of 268 npm and 204 PyPI packages and in the built-in standard library extensions of CPython and Node.js. It analyzes most extensions in under ten seconds, and the errors it finds range from hard crashes to silently incorrect output. We have filed 58 issues in 45 of these projects, of which 26 have been fixed.
Explore related subjects
Keep this discovery
Explore connections, maps & timelines
Thodoris Sotiropoulos, Georgios Alexopoulos, Dimitris Mitropoulos. 2026-11-27. A View from the Bridge: Detecting Boundary Type Errors in Native Extensions of Dynamic Languages. https://arxiv.science/abs/2611.37595
Citations retain the original authors and DOI and include this site’s record URL. If this discovery service contributed to your research, you can also cite arXiv Science by Indiciae: BibTeX · RIS.