Repository: pytorch
Issue: C++ API `at::quantized_max_pool2d`: Heap-buffer-overflow
Labels: oncall: quantization

### 🐛 Describe the bug

`at::quantized_max_pool2d`  causes heap buffer overflow with specific input.

Test code:
```cpp
#include <torch/torch.h>

int main() {
  auto base = torch::randn({1,1});
  torch::Tensor self = at::quantize_per_tensor(base, 0.1, 10, c10::kQInt32);
  at::quantized_max_pool2d(self, {0,0}, {}, {0}, {0,0}, true);

  return 0;
}
```

Error log:
```
=================================================================
==850036==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6020003b0f98 at pc 0x7f1909f11c29 bp 0x7ffc98730830 sp 0x7ffc98730828
READ of size 8 at 0x6020003b0f98 thread T0
    #0 0x7f1909f11c28 in at::native::quantized_max_pool2d(at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool)::$_0::operator()() const::'lambda1'()::operator()() const /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/native/quantized/cpu/Pooling.cpp:640:3
    #1 0x7f1909f0f448 in at::native::quantized_max_pool2d(at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool)::$_0::operator()() const /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/native/quantized/cpu/Pooling.cpp:640:3
    #2 0x7f1909f0b723 in at::native::quantized_max_pool2d(at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool) /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/native/quantized/cpu/Pooling.cpp:640:3
    #3 0x7f19111ed91c in at::(anonymous namespace)::(anonymous namespace)::wrapper_QuantizedCPU__quantized_max_pool2d(at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool) /home/yonghyeon/pytorch/pytorch-asan/build/aten/src/ATen/RegisterQuantizedCPU.cpp:318:10
    #4 0x7f19111eeab5 in c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool), &(at::(anonymous namespace)::(anonymous namespace)::wrapper_QuantizedCPU__quantized_max_pool2d(at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool))>, at::Tensor, c10::guts::typelist::typelist<at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool> >::operator()(at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool) /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/boxing/impl/WrapFunctionIntoFunctor.h:13:16
    #5 0x7f19111eeab5 in c10::impl::wrap_kernel_functor_unboxed_<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool), &(at::(anonymous namespace)::(anonymous namespace)::wrapper_QuantizedCPU__quantized_max_pool2d(at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool))>, at::Tensor, c10::guts::typelist::typelist<at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool> >, at::Tensor (at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool)>::call(c10::OperatorKernel*, c10::DispatchKeySet, at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool) /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/boxing/impl/make_boxed_from_unboxed_functor.h:468:14
    #6 0x7f19111ef54a in std::decay<c10::guts::infer_function_traits<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool), &(at::(anonymous namespace)::(anonymous namespace)::wrapper_QuantizedCPU__quantized_max_pool2d(at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool))>, at::Tensor, c10::guts::typelist::typelist<at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool> > >::type::return_type>::type c10::impl::call_functor_with_args_from_stack_<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool), &(at::(anonymous namespace)::(anonymous namespace)::wrapper_QuantizedCPU__quantized_max_pool2d(at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool))>, at::Tensor, c10::guts::typelist::typelist<at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool> >, false, 0ul, 1ul, 2ul, 3ul, 4ul, 5ul, at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool>(c10::OperatorKernel*, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<std::vector> >*, std::integer_sequence<unsigned long, 0ul, 1ul, 2ul, 3ul, 4ul, 5ul>, c10::guts::typelist::typelist<at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool>*) /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/boxing/impl/make_boxed_from_unboxed_functor.h:503:12
    #7 0x7f19111ef006 in std::decay<c10::guts::infer_function_traits<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool), &(at::(anonymous namespace)::(anonymous namespace)::wrapper_QuantizedCPU__quantized_max_pool2d(at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool))>, at::Tensor, c10::guts::typelist::typelist<at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool> > >::type::return_type>::type c10::impl::call_functor_with_args_from_stack<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool), &(at::(anonymous namespace)::(anonymous namespace)::wrapper_QuantizedCPU__quantized_max_pool2d(at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool))>, at::Tensor, c10::guts::typelist::typelist<at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool> >, false>(c10::OperatorKernel*, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<std::vector> >*) /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/boxing/impl/make_boxed_from_unboxed_functor.h:518:12
    #8 0x7f19111eed19 in c10::impl::make_boxed_from_unboxed_functor<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool), &(at::(anonymous namespace)::(anonymous namespace)::wrapper_QuantizedCPU__quantized_max_pool2d(at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool))>, at::Tensor, c10::guts::typelist::typelist<at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool> >, false>::call(c10::OperatorKernel*, c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/boxing/impl/make_boxed_from_unboxed_functor.h:584:30
    #9 0x7f1907169400 in c10::BoxedKernel::callBoxed(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/boxing/BoxedKernel_impl.h:41:5
    #10 0x7f190716880e in c10::KernelFunction::callBoxed(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/boxing/KernelFunction_impl.h:43:22
    #11 0x7f1907168221 in c10::Dispatcher::redispatchBoxed(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/dispatch/Dispatcher.h:781:17
    #12 0x7f190716473a in c10::OperatorHandle::redispatchBoxed(c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/dispatch/Dispatcher.h:469:34
    #13 0x7f191a0fbc37 in torch::autograd::autogradNotImplementedFallbackImpl(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) /home/yonghyeon/pytorch/pytorch-asan/torch/csrc/autograd/autograd_not_implemented_fallback.cpp:348:8
    #14 0x7f191a100f4f in void c10::BoxedKernel::make_boxed_function<&(torch::autograd::autogradNotImplementedFallbackImpl(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*))>(c10::OperatorKernel*, c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/boxing/BoxedKernel_impl.h:25:5
    #15 0x7f1907169400 in c10::BoxedKernel::callBoxed(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/boxing/BoxedKernel_impl.h:41:5
    #16 0x7f190ab5daac in c10::impl::BoxedKernelWrapper<at::Tensor (at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool), void>::call(c10::BoxedKernel const&, c10::OperatorHandle const&, c10::DispatchKeySet, at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool) /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/boxing/impl/boxing.h:227:23
    #17 0x7f190b26f8ec in at::Tensor c10::KernelFunction::call<at::Tensor, at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool>(c10::OperatorHandle const&, c10::DispatchKeySet, at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool) const /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/boxing/KernelFunction_impl.h:107:12
    #18 0x7f190b26f8ec in at::Tensor c10::Dispatcher::call<at::Tensor, at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool>(c10::TypedOperatorHandle<at::Tensor (at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool)> const&, at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool) const /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/dispatch/Dispatcher.h:694:28
    #19 0x7f190b26f8ec in c10::TypedOperatorHandle<at::Tensor (at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool)>::call(at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool) const /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/dispatch/Dispatcher.h:527:41
    #20 0x7f190b26f8ec in at::_ops::quantized_max_pool2d::call(at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool) /home/yonghyeon/pytorch/pytorch-asan/build/aten/src/ATen/Operators_1.cpp:3872:15
    #21 0x406b1c in at::quantized_max_pool2d(at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool) /home/yonghyeon/pytorch/pytorch-asan/build/aten/src/ATen/ops/quantized_max_pool2d.h:27:12
    #22 0x404db4 in main /home/yonghyeon/pytorch/pytorch-asan/test/cpp/reproduce/quantized_max_pool2d.cpp:6:3
error: failed to decompress '.debug_aranges', zlib is not available
error: failed to decompress '.debug_info', zlib is not available
error: failed to decompress '.debug_abbrev', zlib is not available
error: failed to decompress '.debug_line', zlib is not available
error: failed to decompress '.debug_str', zlib is not available
error: failed to decompress '.debug_line_str', zlib is not available
error: failed to decompress '.debug_loclists', zlib is not available
error: failed to decompress '.debug_rnglists', zlib is not available
    #23 0x7f18fa766d8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
    #24 0x7f18fa766e3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e3f)
    #25 0x404444 in _start (/home/yonghyeon/pytorch/pytorch-asan/build/bin/reproduce_quantized_max_pool2d+0x404444)

0x6020003b0f98 is located 0 bytes to the right of 8-byte region [0x6020003b0f90,0x6020003b0f98)
allocated by thread T0 here:
    #0 0x7f19318cf0bd in operator new(unsigned long) /tmp/llvm/utils/release/final/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:99:3
    #1 0x7f190718cae9 in std::__new_allocator<long>::allocate(unsigned long, void const*) /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/new_allocator.h:137:27
    #2 0x7f190718ca70 in std::allocator_traits<std::allocator<long> >::allocate(std::allocator<long>&, unsigned long) /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/alloc_traits.h:464:20
    #3 0x7f190718c84f in std::_Vector_base<long, std::allocator<long> >::_M_allocate(unsigned long) /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_vector.h:378:20
    #4 0x7f1907231295 in std::vector<long, std::allocator<long> >::reserve(unsigned long) /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/vector.tcc:79:22
    #5 0x7f1907230e1c in std::vector<long, std::allocator<long> > c10::generic_to<long>(c10::IValue, c10::_fake_type<std::vector<long, std::allocator<long> > >) /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/ivalue_inl.h:1774:10
    #6 0x7f1907230b96 in std::vector<long, std::allocator<long> > c10::IValue::to<std::vector<long, std::allocator<long> > >() && /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/ivalue_inl.h:1951:10
    #7 0x7f1907230a3e in c10::impl::ivalue_to_arg<std::vector<long, std::allocator<long> >, false>::call(c10::IValue&) /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/boxing/impl/make_boxed_from_unboxed_functor.h:325:27
    #8 0x7f19072306f2 in c10::impl::ivalue_to_arg<c10::ArrayRef<long>, false>::call(c10::IValue&) /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/boxing/impl/make_boxed_from_unboxed_functor.h:365:14
    #9 0x7f19111ef3d4 in std::decay<c10::guts::infer_function_traits<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool), &(at::(anonymous namespace)::(anonymous namespace)::wrapper_QuantizedCPU__quantized_max_pool2d(at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool))>, at::Tensor, c10::guts::typelist::typelist<at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool> > >::type::return_type>::type c10::impl::call_functor_with_args_from_stack_<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool), &(at::(anonymous namespace)::(anonymous namespace)::wrapper_QuantizedCPU__quantized_max_pool2d(at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool))>, at::Tensor, c10::guts::typelist::typelist<at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool> >, false, 0ul, 1ul, 2ul, 3ul, 4ul, 5ul, at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool>(c10::OperatorKernel*, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<std::vector> >*, std::integer_sequence<unsigned long, 0ul, 1ul, 2ul, 3ul, 4ul, 5ul>, c10::guts::typelist::typelist<at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool>*) /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/boxing/impl/make_boxed_from_unboxed_functor.h:504:7
    #10 0x7f19111ef006 in std::decay<c10::guts::infer_function_traits<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool), &(at::(anonymous namespace)::(anonymous namespace)::wrapper_QuantizedCPU__quantized_max_pool2d(at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool))>, at::Tensor, c10::guts::typelist::typelist<at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool> > >::type::return_type>::type c10::impl::call_functor_with_args_from_stack<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool), &(at::(anonymous namespace)::(anonymous namespace)::wrapper_QuantizedCPU__quantized_max_pool2d(at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool))>, at::Tensor, c10::guts::typelist::typelist<at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool> >, false>(c10::OperatorKernel*, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<std::vector> >*) /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/boxing/impl/make_boxed_from_unboxed_functor.h:518:12
    #11 0x7f19111eed19 in c10::impl::make_boxed_from_unboxed_functor<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool), &(at::(anonymous namespace)::(anonymous namespace)::wrapper_QuantizedCPU__quantized_max_pool2d(at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool))>, at::Tensor, c10::guts::typelist::typelist<at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool> >, false>::call(c10::OperatorKernel*, c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/boxing/impl/make_boxed_from_unboxed_functor.h:584:30
    #12 0x7f1907169400 in c10::BoxedKernel::callBoxed(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/boxing/BoxedKernel_impl.h:41:5
    #13 0x7f190716880e in c10::KernelFunction::callBoxed(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/boxing/KernelFunction_impl.h:43:22
    #14 0x7f1907168221 in c10::Dispatcher::redispatchBoxed(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/dispatch/Dispatcher.h:781:17
    #15 0x7f190716473a in c10::OperatorHandle::redispatchBoxed(c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/dispatch/Dispatcher.h:469:34
    #16 0x7f191a0fbc37 in torch::autograd::autogradNotImplementedFallbackImpl(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) /home/yonghyeon/pytorch/pytorch-asan/torch/csrc/autograd/autograd_not_implemented_fallback.cpp:348:8
    #17 0x7f191a100f4f in void c10::BoxedKernel::make_boxed_function<&(torch::autograd::autogradNotImplementedFallbackImpl(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*))>(c10::OperatorKernel*, c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/boxing/BoxedKernel_impl.h:25:5
    #18 0x7f1907169400 in c10::BoxedKernel::callBoxed(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/boxing/BoxedKernel_impl.h:41:5
    #19 0x7f190ab5daac in c10::impl::BoxedKernelWrapper<at::Tensor (at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool), void>::call(c10::BoxedKernel const&, c10::OperatorHandle const&, c10::DispatchKeySet, at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool) /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/boxing/impl/boxing.h:227:23
    #20 0x7f190b26f8ec in at::Tensor c10::KernelFunction::call<at::Tensor, at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool>(c10::OperatorHandle const&, c10::DispatchKeySet, at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool) const /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/boxing/KernelFunction_impl.h:107:12
    #21 0x7f190b26f8ec in at::Tensor c10::Dispatcher::call<at::Tensor, at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool>(c10::TypedOperatorHandle<at::Tensor (at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool)> const&, at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool) const /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/dispatch/Dispatcher.h:694:28
    #22 0x7f190b26f8ec in c10::TypedOperatorHandle<at::Tensor (at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool)>::call(at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool) const /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/core/dispatch/Dispatcher.h:527:41
    #23 0x7f190b26f8ec in at::_ops::quantized_max_pool2d::call(at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool) /home/yonghyeon/pytorch/pytorch-asan/build/aten/src/ATen/Operators_1.cpp:3872:15
    #24 0x406b1c in at::quantized_max_pool2d(at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool) /home/yonghyeon/pytorch/pytorch-asan/build/aten/src/ATen/ops/quantized_max_pool2d.h:27:12
    #25 0x404db4 in main /home/yonghyeon/pytorch/pytorch-asan/test/cpp/reproduce/quantized_max_pool2d.cpp:6:3
    #26 0x7f18fa766d8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/native/quantized/cpu/Pooling.cpp:640:3 in at::native::quantized_max_pool2d(at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, bool)::$_0::operator()() const::'lambda1'()::operator()() const
Shadow bytes around the buggy address:
  0x0c048006e1a0: fa fa 00 00 fa fa fd fd fa fa fd fd fa fa fd fd
  0x0c048006e1b0: fa fa 00 00 fa fa 00 00 fa fa 00 00 fa fa fd fd
  0x0c048006e1c0: fa fa fd fd fa fa fd fd fa fa 00 00 fa fa 00 00
  0x0c048006e1d0: fa fa 00 00 fa fa fd fa fa fa 00 00 fa fa 00 fa
  0x0c048006e1e0: fa fa 00 fa fa fa 00 fa fa fa 00 00 fa fa 00 00
=>0x0c048006e1f0: fa fa 00[fa]fa fa 00 00 fa fa fa fa fa fa fa fa
  0x0c048006e200: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c048006e210: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c048006e220: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c048006e230: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c048006e240: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==850036==ABORTING
```

### Versions

PyTorch version: 2.3.0a0+git1ee7950
Is debug build: True
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.2 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: 12.0.1
CMake version: version 3.26.4
Libc version: glibc-2.35

Python version: 3.12.0 | packaged by Anaconda, Inc. | (main, Oct  2 2023, 17:29:18) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.0-89-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):                             96
On-line CPU(s) list:                0-95
Vendor ID:                          GenuineIntel
Model name:                         Intel(R) Xeon(R) Gold 6248R CPU @ 3.00GHz
CPU family:                         6
Model:                              85
Thread(s) per core:                 2
Core(s) per socket:                 24
Socket(s):                          2
Stepping:                           7
CPU max MHz:                        4000.0000
CPU min MHz:                        1200.0000
BogoMIPS:                           6000.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.5 MiB (48 instances)
L1i cache:                          1.5 MiB (48 instances)
L2 cache:                           48 MiB (48 instances)
L3 cache:                           71.5 MiB (2 instances)
NUMA node(s):                       2
NUMA node0 CPU(s):                  0-23,48-71
NUMA node1 CPU(s):                  24-47,72-95
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 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 IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Mitigation; TSX disabled

Versions of relevant libraries:
[pip3] numpy==1.26.2
[pip3] optree==0.10.0
[pip3] torch==2.3.0a0+git1ee7950
[conda] mkl                       2023.1.0         h213fc3f_46344  
[conda] mkl-include               2023.1.0         h06a4308_46344  
[conda] numpy                     1.26.2                   pypi_0    pypi
[conda] optree                    0.10.0                   pypi_0    pypi
[conda] torch                     2.3.0a0+git1ee7950           dev_0    <develop>

cc @jerryzh168 @jianyuh @raghuramank100 @jamesr66a @vkuzo @jgong5 @Xia-Weiwen @leslie-fang-intel