Skip to content

migrate: nullable-by-evidence function-pointer parameters as a corpus fixed point (D107); the migrator is NON-COMPLIANT until this lands #2240

Closed

Description

@ehartford

D107 (2026-10-06, Eric) rules that a migrated definition's function-pointer parameter is Option by evidence, computed as a least fixed point over the corpus, with system-header prototypes under D102 unchanged. The shipped migrator wraps by declaration site (ClangBridge.w migration-session rule, PR #2218) and is non-compliant.

Implementation (conforming projection in the D107 entry and ffi.md §16.6):

  • CiProject gains the evidence pass over every scanned unit: per corpus definition and parameter, (a) a body NULL test whose NULL branch continues (p == NULL, p != NULL, !p, if (p), p ? :) → Option; a test whose NULL branch aborts (assert(p), abort()/exit()/__builtin_trap()) → evidence of non-null; (b) a corpus call site passing NULL or a null-like (T)0 at that position → Option; (c) passing p to an Option parameter of a corpus definition, storing it into a record field, or assigning it to a nullable global → Option (the fixed point).
  • Least fixed point: start non-null, add Option from (a)/(b), iterate (c) to closure; an unanalyzable body or a dependency with no corpus definition (outside system headers) is Option; cycles are Option for every member. Deterministic in the corpus, never in unit order.
  • The bridge stops wrapping parameters in migration sessions; CImport renders the signature and the body copy from the project's verdict (one owner).
  • Each verdict prints its reason (f param 2: Option: body tests at line N / Option: caller g at X passes NULL / Option: passed to h param 1 / non-null: called unconditionally, no NULL callers) in the migration log and the shared defs manifest.
  • Fixtures: bs_check_migrate_nullable_fn_pointer gains the handled-test, assert, NULL-caller, field-store and non-null cases; corpora re-migrated, audited with tools/migrate_diff.w, re-promoted.

Ruling PR: #2239.

Activity

  1. ehartford commented on Oct 7, 2026

    @ehartford
    ContributorAuthor

    Implemented on PR #2243 (717bf6b): evidence pass + least fixed point in CiProject, bridge wrap removed, ci_migrated_param_type the one render site, NULL-comparison fold for non-null parameters, reasons printed, fixture with the five cases. Corpora re-promoted; migrate_diff per corpus: pcre2 4 functions (pcre2test), zlib 1 file (inflateBack's callbacks non-null), tommyds 5 test functions, c_algorithms 4 files (list_sort/arraylist/slist callbacks, run_test). pcre2_set_callout keeps Option (NULL callers). Battery pending.

  2. ehartford commented on Oct 7, 2026

    @ehartford
    ContributorAuthor

    Battery #3 on #2243 found a hole in the evidence pass: NULL callers inside static definitions were never recorded (the scan skipped static functions before recording evidence), so pcre2test's own pcre2_jit_stack_assign(ctx, NULL, NULL) and pcre2_set_recursion_memory_management(ctx, NULL, NULL, NULL) went unseen and both setters migrated non-null — the stored-bundle drift harness then refused the corpus's own null. Fixed: every static definition's body contributes NULL-caller evidence (record_call_evidence); the corpora re-migrate; the harness edit is reverted (the parameters are Option again, by evidence).

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