Skip to content

Audit runtime FFI aggregate-to-pointer casts #368

@ehartford

Description

@ehartford

Runtime FFI code should be audited for cases where a With aggregate value is cast directly to a C pointer type instead of extracting the field that the foreign API expects.

Issue #340 was caused by exactly this pattern in rt/regex_runtime.w: text as *const u8 passed the address/representation of a With str value to PCRE2 rather than the string data pointer. The fix was to extract the data pointer explicitly with regex_str_data(text).

Scope for this follow-up:

  • Search runtime and compiler-owned FFI bridge code for casts from aggregate/value types directly to raw C pointers.
  • Treat str, slices, arrays, structs, and runtime wrapper types as suspicious unless the code is intentionally passing the aggregate storage.
  • Verify each C/foreign API boundary receives the representation it declares: data pointer, struct pointer, array pointer, or owned C string.
  • Add helper functions where repeated representation extraction is needed, instead of ad hoc casts.
  • Add focused behavior tests for any corrected bridge path.

Known fixed instance:

  • rt/regex_runtime.w PCRE2 subject pointer extraction fixed by 2d8bfe01.

This is not a release blocker for v0.15.1 unless a concrete failing bridge is found. It is a correctness audit to prevent recurrence of the #340 bug class.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions