Skip to content

Agent crash: an out-of-range integer frame arg (near Int.max) traps Int arithmetic and kills the app #264

Description

@Ti-03

The AI agent runs LLM-generated tool calls carrying frame numbers (startFrame, atFrame, toFrame, durationFrames, trim frames). These are only lower-bounded (>= 0 / >= 1), with no upper bound.

An integer near Int.max is finite (so it passes the decode-time finiteness check in decodeToolArgs) and fits in Int (so it decodes cleanly, unlike 1e19, which JSONDecoder rejects when decoding into Int). It then flows into startFrame + durationFrames (Clip.endFrame in Timeline.swift, clearRegion(end:), placeClip). Swift traps on Int overflow, and that trap is not catchable by the do/catch in ToolExecutor.execute, so the whole app crashes instead of returning a tool error.

This is the same failure class as the 1e19 overflow fixed in #201, resurfacing in the tools that were not routed through clampInt.

Reproduction

Via the agent / MCP:

add_clips { entries: [{ mediaRef: <any>, startFrame: 9223372036854775807, durationFrames: 60 }] }

Also reachable via insert_clips (atFrame), move_clips (toFrame), set_clip_properties (durationFrames/trims), add_texts, and apply_layout.

Notes

Confirmed against main (cdd63ff) with a test that drives add_clips at Int.max: the test process is killed with SIGTRAP the moment the tool runs. I have a small, test-backed fix ready if it would be useful.

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