Skip to content

Engine function spans misaligned in some Lua/Matlab/TS files -- the slice is not the function #3339

Closed

Description

@squid-protocol

Problem

In some files the engine's extracted function span is not the function: the slice splice() returns for a unit starts or ends in the wrong place, so any analysis that reads a unit's body reads other code.

The #3315 hand-label pass (tests/tools/wrapper_labels.json, labels whose reason says "span misaligned") found 6 of 65 sampled units like this on language-crucible v1.4.0:

unit what the slice contained
lua/cosmopolitan/heavy.lua::aux a neighbouring test function's code
lua/cosmopolitan/nextvar.lua::mp2 code above mp2's definition
lua/cosmopolitan/all.lua::round a local-alias declaration line, not round's body
matlab/eeglab/eeg_eval.m::update_datafield mid-function code, not the definition
typescript/playwright/dispatcher.ts::collect the enclosing method's controller.abort(...)
typescript/vscode/lifecycle.ts::dispose the enclosing code's catch/rethrow

Why it matters

  • Wrapper detection (Epic: detect project-local idiom wrappers as a fact channel (follow-up to #3003) #3313): a misaligned span imports another function's print/abort hit. The wrapper channel works around it by requiring the unit's name in the span's first 3 lines (wrapper_extractor's aligned flag).
  • Every per-unit metric from the same slice (complexity, LOC, calls_out_to, unreferenced_by_name) has the same exposure in these files.

Next step

Reproduce each case with galaxyscope <file-dir> --db-only --debug (the [WORKER-TRACE] extracted functions line) and compare start_line/end_line with the source. Lua looks like the concentrated case: 3 of the 6, all in cosmopolitan's test files.

Found during epic #3313, step 1 (#3315).

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

    bugcore-engine

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions