Skip to content

View invalidation is flow-insensitive: a domain-touching call on a branch that returns poisons a view used only on the fall-through path #1655

Closed

Description

@ehartford

Found writing the libcurl behavior fixture for D66 (test/behavior/behav_libcurl_facade_setopt.w). The shape every application writes:

    let info = curl_version_info(CURLVERSION_NOW)     // Option[&curl_version_info_data], borrowed from domain version_info
    if info.is_none():
        print("libcurl version info failed")
        curl_global_cleanup()                          // touches the domain — on a path that returns
        return 1
    print(f"version_num: {info.unwrap().version_num > 0}")   // reached only when the branch above did not run

is refused:

error: view `info` borrows from foreign-state domain `version_info`, which `curl_global_cleanup` may have invalidated (§16.2b.7)
  = label view borrowed here
  = label `curl_global_cleanup` is called here; its effect on foreign-state domain `version_info` is unknown, and unknown effect means invalidate
  = label used here after the call

The call sits on a branch that returns, so no path reaches the use after it; the poisoning (SemaCheck.w facade_apply_call_touches / facade_poison_foreign_views) is in source order, not per path. The same holds for resource-backed views (h.rec() then h.bump() in an early-return branch). The fixture and the UAT read the field before any branch (let version_num = if info.is_none(): 0 else: info.unwrap().version_num), which is fine code but a workaround for the checker, not what §16.2b.7 requires ("later operations that invalidate the resource invalidate the view through ordinary view-liveness rules" — the ordinary rules are path-sensitive).

Route: the poison should be applied at the join, per predecessor — the way the move checker's save_moved_field_state / set_moved_field_union do for field moves — so a call on a returning branch leaves the fall-through path's views live.

Activity

  1. ehartford commented on Sep 26, 2026

    @ehartford
    ContributorAuthor

    Fixed on main by #1705 (db89bc5): foreign-view poison travels in the branch snapshot; a returning branch's call leaves the fall-through view live.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions