viable/strict/1788641405: Fix iterator validity check order in validate_allocation_plan (#196107)
- PyTorch: 566 events in the last 90 days
- PyTorch: 560th Release in the last 90 days
- Previous: earlier the same day · viable/strict/1788623399
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