← Back to events
ActiveAIRelease

viable/strict/1788641405: Fix iterator validity check order in validate_allocation_plan (#196107)

Photo: PyTorch Releases

What happened

In validate_allocation_plan, when processing a Free event, the code dereferenced the iterator returned by allocations.find() before checking whether the iterator was valid (i.e., not equal to allocations.end()). This causes undefined behavior when the allocation plan is invalid and a free event does not have a matching allocate event. Fix by moving the it != allocations.end() TORCH_CHECK before the dereference. "Enf…

Summary assembled by rule from the sources below

Why it's spreading

Sources