Skip to main content

Module cross_language

Module cross_language 

Source
Expand description

Cross-language FFI reachability analysis.

Build a cross-language reach Program:

use weir::cross_language::cross_language;

let program = cross_language(
    4, "source", "sink", "post_cross",
    "current", "next", "changed", "seed", "out",
).unwrap();

cross_language - forward reachability that requires the flow to cross at least one cross-language FFI edge anywhere on the source-to-sink path.

The merged polyglot ProgramGraph (built upstream by surge_frontend::pipeline::merge_polyglot) carries language-specific CALL_ARG edges plus a small set of “FFI” edges that span languages - Python ctypes → C symbol, JNI Java→C, N-API JS→C, Rust bindgen Rust→C. The vanilla flows_to primitive treats all edges identically and therefore fires on intra-language flows that never cross a language boundary; this primitive constrains the path to traverse at least one FFI edge so cross-language detection is precise.

Lowering shape (composes existing Tier-2.5 primitives):

  1. Source-side reach. Run bitset_fixpoint-driven BFS from the source over the full graph. This models intra-language setup before a boundary crossing.
  2. Mandatory FFI bridge. Run csr_forward_traverse from the source-side reach set restricted to the EDGE_KIND_FFI mask. The output (post_cross) is exactly the callee-side nodes reached through at least one cross-language edge.
  3. Free-form continuation. Run bitset_fixpoint-driven BFS from post_cross over the full edge mask. The fixpoint output is the set of nodes the source can reach after crossing the language boundary.
  4. Sink intersection. AND the reach with the sink bitset; the output is non-empty iff some source reaches some sink across a language boundary.

Soundness: MayOver. The BFS over-approximates calls (we model every FFI edge as reachable, even when feature flags / arch gates would prune the call site). Rules that need precision must compose with a sanitizer-dominator filter.

Structs§

CrossLanguage
Soundness marker for cross_language.

Constants§

EDGE_KIND_ALL
Edge-kind mask covering “everything” (post-crossing flow uses any edge). The exact value mirrors csr_forward_traverse’s “all” dispatch convention.
EDGE_KIND_FFI
Edge-kind mask reserved for FFI / cross-language CALL_ARG edges. Aligns with the vyre_primitives::predicate::edge_kind namespace

Functions§

cross_language
Build the cross-language reach Program.