Skip to content

fix(executor): reject oversized integer results before ** / << / *#2512

Open
axelray-dev wants to merge 1 commit into
huggingface:mainfrom
axelray-dev:fix/2473-int-result-bit-limit
Open

fix(executor): reject oversized integer results before ** / << / *#2512
axelray-dev wants to merge 1 commit into
huggingface:mainfrom
axelray-dev:fix/2473-int-result-bit-limit

Conversation

@axelray-dev

Copy link
Copy Markdown

Summary

Fixes #2473.

The local Python executor could still freeze on a single oversized integer operation (**, <<, large *) because thread-based timeouts cannot interrupt CPython integer work under the GIL. MAX_OPERATIONS does not help for one AST node.

This change estimates result bit length before those operations and raises InterpreterError when the estimate exceeds MAX_INT_RESULT_BITS (10_000_000).

Changes

  • Add MAX_INT_RESULT_BITS next to the existing executor limits
  • Guard integer **, <<, and large * in evaluate_binop
  • Add regression tests for oversized and normal cases

Verification

  • pytest tests/test_local_python_executor.py -q (403 passed, 2 skipped)
  • ruff check/format clean on touched files

Backwards compatibility

Normal small integer arithmetic is unchanged. Only results estimated above the bit-length cap are rejected early.

@axelray-dev axelray-dev marked this pull request as ready for review July 13, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Thread-based timeout cannot interrupt single big-integer operations

1 participant