Skip to content

fix(kernels): reject INT32_MAX index in TensorListScatter resize - #127438

Merged
copybara-service[bot] merged 1 commit into
tensorflow:masterfrom
adi-IL:fix/tensorlist-scatter-int32-max
Sep 25, 2026
Merged

copybara-service[bot] merged 1 commit into
tensorflow:masterfrom
adi-IL:fix/tensorlist-scatter-int32-max

Conversation

@adi-IL

@adi-IL adi-IL commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Why

TensorListScatter resized its backing vector with signed
highest_index + 1. When an index equals INT32_MAX, that addition
overflows (undefined behavior) before the resize. The sibling op
TensorListScatterIntoExistingList already rejects this case; Scatter did
not.

Scope

  • In tensorflow/core/kernels/list_kernels.h (TensorListScatter):
    reject highest_index == INT32_MAX with InvalidArgument, and compute
    the resize length as size_t.
  • Add testScatterRejectsUnrepresentableLength next to the existing
    IntoExistingList coverage.

No dilation GPU, LinSpace, RollKernel, Conv2DBackpropInput,
LookupTableExportOp, fused MatMul bias, or Bessel changes.

Verification

  • New unit test asserts InvalidArgument for index np.iinfo(np.int32).max
    without attempting a multi-gigabyte resize.
  • Existing scatter size / negative-index / num_elements tests unchanged in
    intent.

@google-ml-butler google-ml-butler Bot added the size:S CL Change Size: Small label Sep 15, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request prevents undefined behavior and signed integer overflow in TensorListScatter by ensuring that the calculated list length is representable as an int32_t before resizing. It also adds a corresponding unit test to verify that tensor_list_scatter correctly rejects unrepresentable list lengths. I have no feedback to provide as the changes are correct and include appropriate test coverage.

TensorListScatter resized with signed `highest_index + 1`, which overflows
when the index is INT32_MAX. Apply the same guard already used by
TensorListScatterIntoExistingList and size the backing vector with size_t.
@adi-IL
adi-IL force-pushed the fix/tensorlist-scatter-int32-max branch from 8f9ffef to 2fa1860 Compare September 15, 2026 18:38
@nithyak0204
nithyak0204 requested a review from a team September 16, 2026 04:58
@google-ml-butler google-ml-butler Bot added the awaiting review Pull request awaiting review label Sep 16, 2026
@github-project-automation github-project-automation Bot moved this to Assigned Reviewer in PR Queue Sep 16, 2026
@dmiltr3
dmiltr3 self-requested a review September 16, 2026 17:18

@dmiltr3 dmiltr3 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Internal presubmit tests have passed.

@google-ml-butler google-ml-butler Bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels Sep 16, 2026
@github-project-automation github-project-automation Bot moved this from Assigned Reviewer to Approved by Reviewer in PR Queue Sep 16, 2026
@nithyak0204 nithyak0204 removed awaiting review Pull request awaiting review kokoro:force-run Tests on submitted change labels Sep 17, 2026
@google-ml-butler google-ml-butler Bot added the kokoro:force-run Tests on submitted change label Sep 17, 2026
@nithyak0204 nithyak0204 removed the kokoro:force-run Tests on submitted change label Sep 18, 2026
copybara-service Bot pushed a commit that referenced this pull request Sep 24, 2026
Reverts changelist 983366087

FUTURE_COPYBARA_INTEGRATE_REVIEW=#127438 from adi-IL:fix/tensorlist-scatter-int32-max 2fa1860
PiperOrigin-RevId: 986376221
copybara-service Bot pushed a commit that referenced this pull request Sep 24, 2026
Reverts changelist 983366087

FUTURE_COPYBARA_INTEGRATE_REVIEW=#127438 from adi-IL:fix/tensorlist-scatter-int32-max 2fa1860
PiperOrigin-RevId: 984939314
copybara-service Bot pushed a commit that referenced this pull request Sep 24, 2026
…alysis

Replace TuplePointsToAnalysis and LogicalBuffer usage in LayoutAssignment and
GpuLayoutAssignment with HloDataflowAnalysis and HloValue. Add support in
HloDataflowAnalysis for disabling cross computation control flow propagation and
for propagating CallMarker custom calls so layout assignment preserves per
computation constraint propagation semantics.

Reverts changelist 983366087

FUTURE_COPYBARA_INTEGRATE_REVIEW=#127438 from adi-IL:fix/tensorlist-scatter-int32-max 2fa1860
PiperOrigin-RevId: 646627339
copybara-service Bot pushed a commit that referenced this pull request Sep 24, 2026
host_offload_utils::GetSuccessors and GetPredecessors built a CallGraph of
the whole module whenever a walk stepped across a computation root or
parameter. HostOffloader did the same at three more sites, so a run built one
graph per boundary step of its walks. The two utilities now take the graph as
an argument. HostOffloader builds it once per run, when its first walk
starts, and HostOffloadLegalize passes the graph it already had. The pass
adds and removes only instructions without called computations before its
final HloCSE, so the call sites, and the resulting HLO, are unchanged.

Reverts changelist 986346565

FUTURE_COPYBARA_INTEGRATE_REVIEW=#127438 from adi-IL:fix/tensorlist-scatter-int32-max 2fa1860
PiperOrigin-RevId: 987075240
copybara-service Bot pushed a commit that referenced this pull request Sep 24, 2026
Reverts changelist 983366087

FUTURE_COPYBARA_INTEGRATE_REVIEW=#127438 from adi-IL:fix/tensorlist-scatter-int32-max 2fa1860
PiperOrigin-RevId: 986395048
copybara-service Bot pushed a commit that referenced this pull request Sep 24, 2026
…al bugs

Reverts changelist 983366087

FUTURE_COPYBARA_INTEGRATE_REVIEW=#127438 from adi-IL:fix/tensorlist-scatter-int32-max 2fa1860
PiperOrigin-RevId: 986938899
copybara-service Bot pushed a commit that referenced this pull request Sep 24, 2026
When `block_host_until_done` is false, `~ExecutionWatchdogScope()` releases the `HangWatchdog::Guard` asynchronously via `stream_->DoHostCallback(...)`, so the guard and its `on_timeout` and `pre_abort` callbacks outlive `ExecutionWatchdogScope` and `GpuExecutable::ExecuteThunks()`.

- Copy `ExecutionTimeoutHandler` by value in `ExecutionWatchdogScope::Arm()` instead of capturing a raw `const GpuExecutableRunOptions*` pointer that can dangle when callers allocate `GpuExecutableRunOptions` on the stack.
- Separate `ThunkExecutor::ProgressTracker` from `ThunkExecutor::ScopedProgressTracker` via `std::shared_ptr` so `pre_abort` in `GpuExecutable::ExecuteThunksImpl()` captures `tracker->tracker()` by value while `ScopedProgressTracker` remains a stack-local move-only RAII guard that uninstalls the thread-local pointer when leaving the dispatch scope.

Reverts changelist 986346565

FUTURE_COPYBARA_INTEGRATE_REVIEW=#127438 from adi-IL:fix/tensorlist-scatter-int32-max 2fa1860
PiperOrigin-RevId: 987122634
copybara-service Bot pushed a commit that referenced this pull request Sep 24, 2026
When `block_host_until_done` is false, `~ExecutionWatchdogScope()` releases the `HangWatchdog::Guard` asynchronously via `stream_->DoHostCallback(...)`, so the guard and its `on_timeout` and `pre_abort` callbacks outlive `ExecutionWatchdogScope` and `GpuExecutable::ExecuteThunks()`.

- Copy `ExecutionTimeoutHandler` by value in `ExecutionWatchdogScope::Arm()` instead of capturing a raw `const GpuExecutableRunOptions*` pointer that can dangle when callers allocate `GpuExecutableRunOptions` on the stack.
- Separate `ThunkExecutor::ProgressTracker` from `ThunkExecutor::ScopedProgressTracker` via `std::shared_ptr` so `pre_abort` in `GpuExecutable::ExecuteThunksImpl()` captures `tracker->tracker()` by value while `ScopedProgressTracker` remains a stack-local move-only RAII guard that uninstalls the thread-local pointer when leaving the dispatch scope.

Reverts changelist 986346565

FUTURE_COPYBARA_INTEGRATE_REVIEW=#127438 from adi-IL:fix/tensorlist-scatter-int32-max 2fa1860
PiperOrigin-RevId: 987122634
copybara-service Bot pushed a commit that referenced this pull request Sep 24, 2026
…al bugs

Reverts changelist 983366087

FUTURE_COPYBARA_INTEGRATE_REVIEW=#127438 from adi-IL:fix/tensorlist-scatter-int32-max 2fa1860
PiperOrigin-RevId: 986938899
copybara-service Bot pushed a commit that referenced this pull request Sep 24, 2026
The test was audited across 50 runs and demonstrated a 100% pass rate.

Reverts changelist 983366087

FUTURE_COPYBARA_INTEGRATE_REVIEW=#127438 from adi-IL:fix/tensorlist-scatter-int32-max 2fa1860
PiperOrigin-RevId: 986478904
copybara-service Bot pushed a commit that referenced this pull request Sep 24, 2026
The test was audited across 50 runs and demonstrated a 100% pass rate.

Reverts changelist 983366087

FUTURE_COPYBARA_INTEGRATE_REVIEW=#127438 from adi-IL:fix/tensorlist-scatter-int32-max 2fa1860
PiperOrigin-RevId: 986478904
copybara-service Bot pushed a commit that referenced this pull request Sep 24, 2026
Reverts changelist 983366087

FUTURE_COPYBARA_INTEGRATE_REVIEW=#127438 from adi-IL:fix/tensorlist-scatter-int32-max 2fa1860
PiperOrigin-RevId: 986477398
copybara-service Bot pushed a commit that referenced this pull request Sep 24, 2026
Reverts changelist 983366087

FUTURE_COPYBARA_INTEGRATE_REVIEW=#127438 from adi-IL:fix/tensorlist-scatter-int32-max 2fa1860
PiperOrigin-RevId: 986996926
copybara-service Bot pushed a commit that referenced this pull request Sep 24, 2026
Updates LLVM usage to match
[e56c2cefc3e7](llvm/llvm-project@e56c2ce)

Reverts changelist 983366087

FUTURE_COPYBARA_INTEGRATE_REVIEW=#127438 from adi-IL:fix/tensorlist-scatter-int32-max 2fa1860
PiperOrigin-RevId: 986804242
copybara-service Bot pushed a commit that referenced this pull request Sep 24, 2026
Adds `MismatchDetails::has_element_level_data` (default true). Producers that
only know that an instruction mismatched, not which elements, can set it to
false so the tensor inspector is suppressed instead of showing a fabricated
single-element mismatch.

FUTURE_COPYBARA_INTEGRATE_REVIEW=#127438 from adi-IL:fix/tensorlist-scatter-int32-max 2fa1860
PiperOrigin-RevId: 987543462
@copybara-service
copybara-service Bot merged commit 8a3a427 into tensorflow:master Sep 25, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready to pull PR ready for merge process size:S CL Change Size: Small

Projects

Status: Merged

Development

Successfully merging this pull request may close these issues.

4 participants