Repository: pytorch
Issue: Segmentation fault (core dumped) in `fractional_max_pool3d_backward`
Labels: module: crash,triaged,module: pooling,module: edge cases

### 🐛 Describe the bug

Under specific inputs, `fractional_max_pool3d_backward` triggered a crash.
```python
import torch

grad_output = torch.full((2, 3, 2, 2, 2,), 0.5, dtype=torch.double)
self = torch.full((2, 3, 2, 2, 2,), 0.5, dtype=torch.double)
kernel_size = [2, 2, 2]
output_size = [2, 2, 2]
indices = torch.full((0, 0, 11, 0, 0, 7, 0, 13, 11, 1, 13, 2, 10, 0, 1, 0, 12, 0, 0, 0,), 1.251e+12, dtype=torch.long)
torch.ops.aten.fractional_max_pool3d_backward(grad_output, self, kernel_size, output_size, indices)

```
Output
```
Segmentation fault (core dumped) 
```
ASAN Output
```
==60872==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7ff2885abb80 bp 0x7ffe8857d920 sp 0x7ffe8857d7f0 T0)
==60872==The signal is caused by a READ memory access.
==60872==Hint: address points to the zero page.
    #0 0x7ff2885abb80 in operator() /mnt/pytorch-2.5.0/aten/src/ATen/native/FractionalMaxPool3d.cpp:283
    #1 0x7ff2885b2087 in parallel_for<at::native::(anonymous namespace)::fractional_max_pool3d_backward_out_single_batch_frame<double>(double*, double const*, const int64_t*, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t)::<lambda(int64_t, int64_t)> > /mnt/pytorch-2.5.0/aten/src/ATen/Parallel-inl.h:29
    #2 0x7ff2885ac327 in fractional_max_pool3d_backward_out_single_batch_frame<double> /mnt/pytorch-2.5.0/aten/src/ATen/native/FractionalMaxPool3d.cpp:270
    #3 0x7ff28859e70c in operator() /mnt/pytorch-2.5.0/aten/src/ATen/native/FractionalMaxPool3d.cpp:313
    #4 0x7ff2885ac4f2 in operator() /mnt/pytorch-2.5.0/aten/src/ATen/Parallel-inl.h:36
    #5 0x7ff2885b789f in __invoke_impl<void, at::parallel_for<at::native::(anonymous namespace)::fractional_max_pool3d_backward_out_frame<double>(double*, double const*, const int64_t*, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t)::<lambda(int64_t, int64_t)> >(int64_t, int64_t, int64_t, const at::native::(anonymous namespace)::fractional_max_pool3d_backward_out_frame<double>(double*, double const*, const int64_t*, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t)::<lambda(int64_t, int64_t)>&)::<lambda(int64_t, int64_t)>&, long int, long int> /usr/include/c++/11/bits/invoke.h:61
    #6 0x7ff2885b5d1b in __invoke_r<void, at::parallel_for<at::native::(anonymous namespace)::fractional_max_pool3d_backward_out_frame<double>(double*, double const*, const int64_t*, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t)::<lambda(int64_t, int64_t)> >(int64_t, int64_t, int64_t, const at::native::(anonymous namespace)::fractional_max_pool3d_backward_out_frame<double>(double*, double const*, const int64_t*, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t)::<lambda(int64_t, int64_t)>&)::<lambda(int64_t, int64_t)>&, long int, long int> /usr/include/c++/11/bits/invoke.h:111
    #7 0x7ff2885b4355 in _M_invoke /usr/include/c++/11/bits/std_function.h:290
    #8 0x7ff287532b04 in std::function<void (long, long)>::operator()(long, long) const /usr/include/c++/11/bits/std_function.h:590
    #9 0x7ff28751d2f0 in operator() /mnt/pytorch-2.5.0/aten/src/ATen/ParallelNative.cpp:166
    #10 0x7ff2875215d3 in __invoke_impl<void, at::internal::invoke_parallel(int64_t, int64_t, int64_t, const std::function<void(long int, long int)>&)::<lambda(int, size_t)>&, int, long unsigned int> /usr/include/c++/11/bits/invoke.h:61
    #11 0x7ff2875210e1 in __invoke_r<void, at::internal::invoke_parallel(int64_t, int64_t, int64_t, const std::function<void(long int, long int)>&)::<lambda(int, size_t)>&, int, long unsigned int> /usr/include/c++/11/bits/invoke.h:111
    #12 0x7ff2875209a5 in _M_invoke /usr/include/c++/11/bits/std_function.h:290
    #13 0x7ff2875325f8 in std::function<void (int, unsigned long)>::operator()(int, unsigned long) const /usr/include/c++/11/bits/std_function.h:590
    #14 0x7ff28751ce94 in _run_with_pool /mnt/pytorch-2.5.0/aten/src/ATen/ParallelNative.cpp:96
    #15 0x7ff28751da60 in at::internal::invoke_parallel(long, long, long, std::function<void (long, long)> const&) /mnt/pytorch-2.5.0/aten/src/ATen/ParallelNative.cpp:181
    #16 0x7ff2885ac7c6 in parallel_for<at::native::(anonymous namespace)::fractional_max_pool3d_backward_out_frame<double>(double*, double const*, const int64_t*, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t)::<lambda(int64_t, int64_t)> > /mnt/pytorch-2.5.0/aten/src/ATen/Parallel-inl.h:33
    #17 0x7ff28859ebe5 in fractional_max_pool3d_backward_out_frame<double> /mnt/pytorch-2.5.0/aten/src/ATen/native/FractionalMaxPool3d.cpp:311
    #18 0x7ff28859626e in operator() /mnt/pytorch-2.5.0/aten/src/ATen/native/FractionalMaxPool3d.cpp:375
    #19 0x7ff2885973b7 in operator() /mnt/pytorch-2.5.0/aten/src/ATen/native/FractionalMaxPool3d.cpp:375
    #20 0x7ff288598e04 in fractional_max_pool3d_backward_out_cpu_template /mnt/pytorch-2.5.0/aten/src/ATen/native/FractionalMaxPool3d.cpp:375
    #21 0x7ff2885994b6 in at::native::fractional_max_pool3d_backward_cpu(at::Tensor const&, at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, at::Tensor const&) /mnt/pytorch-2.5.0/aten/src/ATen/native/FractionalMaxPool3d.cpp:418
    #22 0x7ff28c90133b in wrapper_CPU__fractional_max_pool3d_backward /mnt/pytorch-2.5.0/build/aten/src/ATen/RegisterCPU.cpp:23111
```

### Versions

PyTorch version: 2.5.0a0+git32f585d
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.4 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: version 3.22.1
Libc version: glibc-2.35

Python version: 3.13.0 | packaged by Anaconda, Inc. | (main, Oct 7 2024, 21:29:38) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.0-124-generic-x86_64-with-glibc2.35
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 46 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 80
On-line CPU(s) list: 0-79
Vendor ID: GenuineIntel
Model name: Intel(R) Xeon(R) Gold 5218R CPU @ 2.10GHz
CPU family: 6
Model: 85
Thread(s) per core: 2
Core(s) per socket: 20
Socket(s): 2
Stepping: 7
CPU max MHz: 4000.0000
CPU min MHz: 800.0000
BogoMIPS: 4200.00
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single intel_ppin ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts pku ospke avx512_vnni md_clear flush_l1d arch_capabilities
Virtualization: VT-x
L1d cache: 1.3 MiB (40 instances)
L1i cache: 1.3 MiB (40 instances)
L2 cache: 40 MiB (40 instances)
L3 cache: 55 MiB (2 instances)
NUMA node(s): 2
NUMA node0 CPU(s): 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78
NUMA node1 CPU(s): 1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79
Vulnerability Gather data sampling: Mitigation; Microcode
Vulnerability Itlb multihit: KVM: Mitigation: VMX disabled
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed: Mitigation; Enhanced IBRS
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Enhanced / Automatic IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS SW sequence; BHI SW loop, KVM SW loop
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Mitigation; TSX disabled

Versions of relevant libraries:
[pip3] numpy==2.1.3
[pip3] torch==2.5.0a0+git32f585d
[conda] numpy 2.1.3 pypi_0 pypi
[conda] torch 2.5.0a0+git32f585d pypi_0 pypi

cc @mikaylagawarecki