Repository: pytorch
Issue: `torch.nn.utils.rnn.pack_padded_sequence` heap-buffer-overflow
Labels: oncall: quantization,triaged

### 🐛 Describe the bug

`torch.nn.utils.rnn.pack_padded_sequence` has heap-buffer-overflow vulnerability.
Note that it does not crash without ASAN.

Test code:
```python
import torch

t = torch.quantize_per_tensor(torch.randn(2,2,2),0.1,10,torch.quint4x2)
lengths = torch.randn(1)
torch.nn.utils.rnn.pack_padded_sequence(t, lengths, enforce_sorted=False)
```
Error log:
```
=================================================================
==335983==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6090000000c4 at pc 0x7f7b62cc20d7 bp 0x7fffe48b2a50 sp 0x7fffe48b2218
READ of size 2 at 0x6090000000c4 thread T0
    #0 0x7f7b62cc20d6 in __asan_memcpy /tmp/llvm/utils/release/final/llvm-project/compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp:22:3
    #1 0x7f7b29109102 in at::native::index_select_out_cpu_dim1_(at::Tensor&, at::Tensor const&, at::Tensor const&)::$_19::operator()() const::'lambda0'()::operator()() const /home/sehoon/pytorch-latest-asan/aten/src/ATen/native/TensorAdvancedIndexing.cpp:1188:3
    #2 0x7f7b29106715 in at::native::index_select_out_cpu_dim1_(at::Tensor&, at::Tensor const&, at::Tensor const&)::$_19::operator()() const /home/sehoon/pytorch-latest-asan/aten/src/ATen/native/TensorAdvancedIndexing.cpp:1188:3
    #3 0x7f7b29077424 in at::native::index_select_out_cpu_dim1_(at::Tensor&, at::Tensor const&, at::Tensor const&) /home/sehoon/pytorch-latest-asan/aten/src/ATen/native/TensorAdvancedIndexing.cpp:1188:3
    #4 0x7f7b29074a5f in at::native::index_select_out_cpu_(at::Tensor const&, long, at::Tensor const&, at::Tensor&) /home/sehoon/pytorch-latest-asan/aten/src/ATen/native/TensorAdvancedIndexing.cpp:1264:14
    #5 0x7f7b29135c88 in at::native::index_select_quantized_cpu_(at::Tensor const&, long, at::Tensor const&) /home/sehoon/pytorch-latest-asan/aten/src/ATen/native/TensorAdvancedIndexing.cpp:1393:10
    #6 0x7f7b310c3ed2 in at::(anonymous namespace)::(anonymous namespace)::wrapper_QuantizedCPU__index_select(at::Tensor const&, long, at::Tensor const&) /home/sehoon/pytorch-latest-asan/build/aten/src/ATen/RegisterQuantizedCPU.cpp:731:10
    #7 0x7f7b310c487d in c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (at::Tensor const&, long, at::Tensor const&), &(at::(anonymous namespace)::(anonymous namespace)::wrapper_QuantizedCPU__index_select(at::Tensor const&, long, at::Tensor const&))>, at::Tensor, c10::guts::typelist::typelist<at::Tensor const&, long, at::Tensor const&> >::operator()(at::Tensor const&, long, at::Tensor const&) /home/sehoon/pytorch-latest-asan/aten/src/ATen/core/boxing/impl/WrapFunctionIntoFunctor.h:13:16
    #8 0x7f7b310c487d in c10::impl::wrap_kernel_functor_unboxed_<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (at::Tensor const&, long, at::Tensor const&), &(at::(anonymous namespace)::(anonymous namespace)::wrapper_QuantizedCPU__index_select(at::Tensor const&, long, at::Tensor const&))>, at::Tensor, c10::guts::typelist::typelist<at::Tensor const&, long, at::Tensor const&> >, at::Tensor (at::Tensor const&, long, at::Tensor const&)>::call(c10::OperatorKernel*, c10::DispatchKeySet, at::Tensor const&, long, at::Tensor const&) /home/sehoon/pytorch-latest-asan/aten/src/ATen/core/boxing/impl/make_boxed_from_unboxed_functor.h:468:14
    #9 0x7f7b2aae0956 in at::Tensor c10::callUnboxedKernelFunction<at::Tensor, at::Tensor const&, long, at::Tensor const&>(void*, c10::OperatorKernel*, c10::DispatchKeySet, at::Tensor const&, long&&, at::Tensor const&) /home/sehoon/pytorch-latest-asan/aten/src/ATen/core/boxing/KernelFunction_impl.h:50:12
    #10 0x7f7b2aae049f in at::Tensor c10::KernelFunction::call<at::Tensor, at::Tensor const&, long, at::Tensor const&>(c10::OperatorHandle const&, c10::DispatchKeySet, at::Tensor const&, long, at::Tensor const&) const /home/sehoon/pytorch-latest-asan/aten/src/ATen/core/boxing/KernelFunction_impl.h:102:16
    #11 0x7f7b2aae049f in at::Tensor c10::Dispatcher::redispatch<at::Tensor, at::Tensor const&, long, at::Tensor const&>(c10::TypedOperatorHandle<at::Tensor (at::Tensor const&, long, at::Tensor const&)> const&, c10::DispatchKeySet, at::Tensor const&, long, at::Tensor const&) const /home/sehoon/pytorch-latest-asan/aten/src/ATen/core/dispatch/Dispatcher.h:690:26
    #12 0x7f7b2a84c98a in c10::TypedOperatorHandle<at::Tensor (at::Tensor const&, long, at::Tensor const&)>::redispatch(c10::DispatchKeySet, at::Tensor const&, long, at::Tensor const&) const /home/sehoon/pytorch-latest-asan/aten/src/ATen/core/dispatch/Dispatcher.h:526:41
    #13 0x7f7b2a84c98a in at::_ops::index_select::redispatch(c10::DispatchKeySet, at::Tensor const&, long, at::Tensor const&) /home/sehoon/pytorch-latest-asan/build/aten/src/ATen/Operators_0.cpp:9533:15
    #14 0x7f7b35d1cf12 in at::redispatch::index_select(c10::DispatchKeySet, at::Tensor const&, long, at::Tensor const&) /home/sehoon/pytorch-latest-asan/build/aten/src/ATen/RedispatchFunctions.h:10742:16
    #15 0x7f7b35a2ade2 in torch::autograd::VariableType::(anonymous namespace)::index_select(c10::DispatchKeySet, at::Tensor const&, long, at::Tensor const&)::$_104::operator()() const /home/sehoon/pytorch-latest-asan/torch/csrc/autograd/generated/VariableType_0.cpp:9947:12
    #16 0x7f7b35a298b7 in torch::autograd::VariableType::(anonymous namespace)::index_select(c10::DispatchKeySet, at::Tensor const&, long, at::Tensor const&) /home/sehoon/pytorch-latest-asan/torch/csrc/autograd/generated/VariableType_0.cpp:9945:15
    #17 0x7f7b35a2b7b4 in c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (c10::DispatchKeySet, at::Tensor const&, long, at::Tensor const&), &(torch::autograd::VariableType::(anonymous namespace)::index_select(c10::DispatchKeySet, at::Tensor const&, long, at::Tensor const&))>, at::Tensor, c10::guts::typelist::typelist<c10::DispatchKeySet, at::Tensor const&, long, at::Tensor const&> >::operator()(c10::DispatchKeySet, at::Tensor const&, long, at::Tensor const&) /home/sehoon/pytorch-latest-asan/aten/src/ATen/core/boxing/impl/WrapFunctionIntoFunctor.h:13:16
    #18 0x7f7b35a2b7b4 in c10::impl::wrap_kernel_functor_unboxed_<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (c10::DispatchKeySet, at::Tensor const&, long, at::Tensor const&), &(torch::autograd::VariableType::(anonymous namespace)::index_select(c10::DispatchKeySet, at::Tensor const&, long, at::Tensor const&))>, at::Tensor, c10::guts::typelist::typelist<c10::DispatchKeySet, at::Tensor const&, long, at::Tensor const&> >, at::Tensor (c10::DispatchKeySet, at::Tensor const&, long, at::Tensor const&)>::call(c10::OperatorKernel*, c10::DispatchKeySet, at::Tensor const&, long, at::Tensor const&) /home/sehoon/pytorch-latest-asan/aten/src/ATen/core/boxing/impl/make_boxed_from_unboxed_functor.h:485:14
    #19 0x7f7b2aae0956 in at::Tensor c10::callUnboxedKernelFunction<at::Tensor, at::Tensor const&, long, at::Tensor const&>(void*, c10::OperatorKernel*, c10::DispatchKeySet, at::Tensor const&, long&&, at::Tensor const&) /home/sehoon/pytorch-latest-asan/aten/src/ATen/core/boxing/KernelFunction_impl.h:50:12
    #20 0x7f7b2a58f366 in at::Tensor c10::KernelFunction::call<at::Tensor, at::Tensor const&, long, at::Tensor const&>(c10::OperatorHandle const&, c10::DispatchKeySet, at::Tensor const&, long, at::Tensor const&) const /home/sehoon/pytorch-latest-asan/aten/src/ATen/core/boxing/KernelFunction_impl.h:102:16
    #21 0x7f7b2a58f366 in at::Tensor c10::Dispatcher::call<at::Tensor, at::Tensor const&, long, at::Tensor const&>(c10::TypedOperatorHandle<at::Tensor (at::Tensor const&, long, at::Tensor const&)> const&, at::Tensor const&, long, at::Tensor const&) const /home/sehoon/pytorch-latest-asan/aten/src/ATen/core/dispatch/Dispatcher.h:673:26
    #22 0x7f7b2a58f366 in c10::TypedOperatorHandle<at::Tensor (at::Tensor const&, long, at::Tensor const&)>::call(at::Tensor const&, long, at::Tensor const&) const /home/sehoon/pytorch-latest-asan/aten/src/ATen/core/dispatch/Dispatcher.h:521:41
    #23 0x7f7b2a58f366 in at::_ops::index_select::call(at::Tensor const&, long, at::Tensor const&) /home/sehoon/pytorch-latest-asan/build/aten/src/ATen/Operators_0.cpp:9526:15
    #24 0x7f7b5272e802 in at::Tensor::index_select(long, at::Tensor const&) const /home/sehoon/pytorch-latest-asan/build/aten/src/ATen/core/TensorBody.h:5026:12
    #25 0x7f7b52685e34 in torch::autograd::THPVariable_index_select(_object*, _object*, _object*)::$_361::operator()(at::Tensor const&, long, at::Tensor const&) const /home/sehoon/pytorch-latest-asan/torch/csrc/autograd/generated/python_variable_methods.cpp:9024:21
    #26 0x7f7b52568e09 in torch::autograd::THPVariable_index_select(_object*, _object*, _object*) /home/sehoon/pytorch-latest-asan/torch/csrc/autograd/generated/python_variable_methods.cpp:9026:19
    #27 0x4f9ba5 in method_vectorcall_VARARGS_KEYWORDS /usr/local/src/conda/python-3.9.18/Objects/descrobject.c:348:14
    #28 0x4e80b4 in _PyObject_VectorcallTstate /usr/local/src/conda/python-3.9.18/Include/cpython/abstract.h:118:11
    #29 0x4e80b4 in PyObject_Vectorcall /usr/local/src/conda/python-3.9.18/Include/cpython/abstract.h:127:12
    #30 0x4e80b4 in call_function /usr/local/src/conda/python-3.9.18/Python/ceval.c:5077:13
    #31 0x4e80b4 in _PyEval_EvalFrameDefault /usr/local/src/conda/python-3.9.18/Python/ceval.c:3506:23
    #32 0x4e6b29 in _PyEval_EvalFrame /usr/local/src/conda/python-3.9.18/Include/internal/pycore_ceval.h:40:12
    #33 0x4e6b29 in _PyEval_EvalCode /usr/local/src/conda/python-3.9.18/Python/ceval.c:4329:14
    #34 0x4f7e53 in _PyFunction_Vectorcall /usr/local/src/conda/python-3.9.18/Objects/call.c:396:12
    #35 0x4e8c60 in _PyObject_VectorcallTstate /usr/local/src/conda/python-3.9.18/Include/cpython/abstract.h:118:11
    #36 0x4e8c60 in PyObject_Vectorcall /usr/local/src/conda/python-3.9.18/Include/cpython/abstract.h:127:12
    #37 0x4e8c60 in call_function /usr/local/src/conda/python-3.9.18/Python/ceval.c:5077:13
    #38 0x4e8c60 in _PyEval_EvalFrameDefault /usr/local/src/conda/python-3.9.18/Python/ceval.c:3537:19
    #39 0x4e6b29 in _PyEval_EvalFrame /usr/local/src/conda/python-3.9.18/Include/internal/pycore_ceval.h:40:12
    #40 0x4e6b29 in _PyEval_EvalCode /usr/local/src/conda/python-3.9.18/Python/ceval.c:4329:14
    #41 0x4e67b6 in _PyEval_EvalCodeWithName /usr/local/src/conda/python-3.9.18/Python/ceval.c:4361:12
    #42 0x4e6768 in PyEval_EvalCodeEx /usr/local/src/conda/python-3.9.18/Python/ceval.c:4377:12
    #43 0x59466a in PyEval_EvalCode /usr/local/src/conda/python-3.9.18/Python/ceval.c:828:12
    #44 0x5c1dc6 in run_eval_code_obj /usr/local/src/conda/python-3.9.18/Python/pythonrun.c:1221:9
    #45 0x5bddcf in run_mod /usr/local/src/conda/python-3.9.18/Python/pythonrun.c:1242:19
    #46 0x45674d in pyrun_file.cold /usr/local/src/conda/python-3.9.18/Python/pythonrun.c:1140:15
    #47 0x5b7ab1 in pyrun_simple_file /usr/local/src/conda/python-3.9.18/Python/pythonrun.c:450:13
    #48 0x5b7ab1 in PyRun_SimpleFileExFlags /usr/local/src/conda/python-3.9.18/Python/pythonrun.c:483:15
    #49 0x5b502d in pymain_run_file /usr/local/src/conda/python-3.9.18/Modules/main.c:379:15
    #50 0x5b502d in pymain_run_python /usr/local/src/conda/python-3.9.18/Modules/main.c:604:21
    #51 0x5b502d in Py_RunMain /usr/local/src/conda/python-3.9.18/Modules/main.c:683:5
    #52 0x588718 in Py_BytesMain /usr/local/src/conda/python-3.9.18/Modules/main.c:1129:12
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
    #53 0x7f7b6291ad8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
    #54 0x7f7b6291ae3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e3f)
    #55 0x5885cd in _start (/home/sehoon/anaconda3/envs/torch-latest-asan/bin/python3.9+0x5885cd)

0x6090000000c4 is located 0 bytes to the right of 4-byte region [0x6090000000c0,0x6090000000c4)
allocated by thread T0 here:
    #0 0x7f7b62cc3807 in posix_memalign /tmp/llvm/utils/release/final/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:226:3
    #1 0x7f7b240c87be in c10::alloc_cpu(unsigned long) /home/sehoon/pytorch-latest-asan/c10/core/impl/alloc_cpu.cpp:82:13
    #2 0x7f7b23fcb4fa in c10::DefaultCPUAllocator::allocate(unsigned long) const /home/sehoon/pytorch-latest-asan/c10/core/CPUAllocator.cpp:23:14
    #3 0x7f7b31636c6c in at::new_qtensor(c10::ArrayRef<long>, c10::TensorOptions const&, c10::intrusive_ptr<at::Quantizer, c10::detail::intrusive_target_default_null_type<at::Quantizer> >) /home/sehoon/pytorch-latest-asan/aten/src/ATen/quantized/Quantizer.cpp:152:18
    #4 0x7f7b3162cc0b in at::PerTensorAffineQuantizer::quantize(at::Tensor const&) /home/sehoon/pytorch-latest-asan/aten/src/ATen/quantized/Quantizer.cpp:168:20
    #5 0x7f7b29cf80ae in at::native::quantize_per_tensor(at::Tensor const&, double, long, c10::ScalarType) /home/sehoon/pytorch-latest-asan/aten/src/ATen/native/quantized/QTensor.cpp:63:21
    #6 0x7f7b2dce3f0d in at::(anonymous namespace)::(anonymous namespace)::wrapper_CPU__quantize_per_tensor(at::Tensor const&, double, long, c10::ScalarType) /home/sehoon/pytorch-latest-asan/build/aten/src/ATen/RegisterCPU.cpp:12844:10
    #7 0x7f7b2dce4b46 in c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (at::Tensor const&, double, long, c10::ScalarType), &(at::(anonymous namespace)::(anonymous namespace)::wrapper_CPU__quantize_per_tensor(at::Tensor const&, double, long, c10::ScalarType))>, at::Tensor, c10::guts::typelist::typelist<at::Tensor const&, double, long, c10::ScalarType> >::operator()(at::Tensor const&, double, long, c10::ScalarType) /home/sehoon/pytorch-latest-asan/aten/src/ATen/core/boxing/impl/WrapFunctionIntoFunctor.h:13:16
    #8 0x7f7b2dce4b46 in c10::impl::wrap_kernel_functor_unboxed_<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (at::Tensor const&, double, long, c10::ScalarType), &(at::(anonymous namespace)::(anonymous namespace)::wrapper_CPU__quantize_per_tensor(at::Tensor const&, double, long, c10::ScalarType))>, at::Tensor, c10::guts::typelist::typelist<at::Tensor const&, double, long, c10::ScalarType> >, at::Tensor (at::Tensor const&, double, long, c10::ScalarType)>::call(c10::OperatorKernel*, c10::DispatchKeySet, at::Tensor const&, double, long, c10::ScalarType) /home/sehoon/pytorch-latest-asan/aten/src/ATen/core/boxing/impl/make_boxed_from_unboxed_functor.h:468:14
    #9 0x7f7b2c2ae858 in at::Tensor c10::callUnboxedKernelFunction<at::Tensor, at::Tensor const&, double, long, c10::ScalarType>(void*, c10::OperatorKernel*, c10::DispatchKeySet, at::Tensor const&, double&&, long&&, c10::ScalarType&&) /home/sehoon/pytorch-latest-asan/aten/src/ATen/core/boxing/KernelFunction_impl.h:50:12
    #10 0x7f7b2c2ae256 in at::Tensor c10::KernelFunction::call<at::Tensor, at::Tensor const&, double, long, c10::ScalarType>(c10::OperatorHandle const&, c10::DispatchKeySet, at::Tensor const&, double, long, c10::ScalarType) const /home/sehoon/pytorch-latest-asan/aten/src/ATen/core/boxing/KernelFunction_impl.h:102:16
    #11 0x7f7b2c2ae256 in at::Tensor c10::Dispatcher::redispatch<at::Tensor, at::Tensor const&, double, long, c10::ScalarType>(c10::TypedOperatorHandle<at::Tensor (at::Tensor const&, double, long, c10::ScalarType)> const&, c10::DispatchKeySet, at::Tensor const&, double, long, c10::ScalarType) const /home/sehoon/pytorch-latest-asan/aten/src/ATen/core/dispatch/Dispatcher.h:690:26
    #12 0x7f7b2c065e7c in c10::TypedOperatorHandle<at::Tensor (at::Tensor const&, double, long, c10::ScalarType)>::redispatch(c10::DispatchKeySet, at::Tensor const&, double, long, c10::ScalarType) const /home/sehoon/pytorch-latest-asan/aten/src/ATen/core/dispatch/Dispatcher.h:526:41
    #13 0x7f7b2c065e7c in at::_ops::quantize_per_tensor::redispatch(c10::DispatchKeySet, at::Tensor const&, double, long, c10::ScalarType) /home/sehoon/pytorch-latest-asan/build/aten/src/ATen/Operators_2.cpp:7941:15
    #14 0x7f7b3695f391 in at::redispatch::quantize_per_tensor(c10::DispatchKeySet, at::Tensor const&, double, long, c10::ScalarType) /home/sehoon/pytorch-latest-asan/build/aten/src/ATen/RedispatchFunctions.h:8997:16
    #15 0x7f7b3671e2f1 in torch::autograd::VariableType::(anonymous namespace)::quantize_per_tensor(c10::DispatchKeySet, at::Tensor const&, double, long, c10::ScalarType)::$_136::operator()() const /home/sehoon/pytorch-latest-asan/torch/csrc/autograd/generated/VariableType_2.cpp:14124:12
    #16 0x7f7b3671d72d in torch::autograd::VariableType::(anonymous namespace)::quantize_per_tensor(c10::DispatchKeySet, at::Tensor const&, double, long, c10::ScalarType) /home/sehoon/pytorch-latest-asan/torch/csrc/autograd/generated/VariableType_2.cpp:14122:15
    #17 0x7f7b3671ef5e in c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (c10::DispatchKeySet, at::Tensor const&, double, long, c10::ScalarType), &(torch::autograd::VariableType::(anonymous namespace)::quantize_per_tensor(c10::DispatchKeySet, at::Tensor const&, double, long, c10::ScalarType))>, at::Tensor, c10::guts::typelist::typelist<c10::DispatchKeySet, at::Tensor const&, double, long, c10::ScalarType> >::operator()(c10::DispatchKeySet, at::Tensor const&, double, long, c10::ScalarType) /home/sehoon/pytorch-latest-asan/aten/src/ATen/core/boxing/impl/WrapFunctionIntoFunctor.h:13:16
    #18 0x7f7b3671ef5e in c10::impl::wrap_kernel_functor_unboxed_<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (c10::DispatchKeySet, at::Tensor const&, double, long, c10::ScalarType), &(torch::autograd::VariableType::(anonymous namespace)::quantize_per_tensor(c10::DispatchKeySet, at::Tensor const&, double, long, c10::ScalarType))>, at::Tensor, c10::guts::typelist::typelist<c10::DispatchKeySet, at::Tensor const&, double, long, c10::ScalarType> >, at::Tensor (c10::DispatchKeySet, at::Tensor const&, double, long, c10::ScalarType)>::call(c10::OperatorKernel*, c10::DispatchKeySet, at::Tensor const&, double, long, c10::ScalarType) /home/sehoon/pytorch-latest-asan/aten/src/ATen/core/boxing/impl/make_boxed_from_unboxed_functor.h:485:14
    #19 0x7f7b2c2ae858 in at::Tensor c10::callUnboxedKernelFunction<at::Tensor, at::Tensor const&, double, long, c10::ScalarType>(void*, c10::OperatorKernel*, c10::DispatchKeySet, at::Tensor const&, double&&, long&&, c10::ScalarType&&) /home/sehoon/pytorch-latest-asan/aten/src/ATen/core/boxing/KernelFunction_impl.h:50:12
    #20 0x7f7b2bd2aa60 in at::Tensor c10::KernelFunction::call<at::Tensor, at::Tensor const&, double, long, c10::ScalarType>(c10::OperatorHandle const&, c10::DispatchKeySet, at::Tensor const&, double, long, c10::ScalarType) const /home/sehoon/pytorch-latest-asan/aten/src/ATen/core/boxing/KernelFunction_impl.h:102:16
    #21 0x7f7b2bd2aa60 in at::Tensor c10::Dispatcher::call<at::Tensor, at::Tensor const&, double, long, c10::ScalarType>(c10::TypedOperatorHandle<at::Tensor (at::Tensor const&, double, long, c10::ScalarType)> const&, at::Tensor const&, double, long, c10::ScalarType) const /home/sehoon/pytorch-latest-asan/aten/src/ATen/core/dispatch/Dispatcher.h:673:26
    #22 0x7f7b2bd2aa60 in c10::TypedOperatorHandle<at::Tensor (at::Tensor const&, double, long, c10::ScalarType)>::call(at::Tensor const&, double, long, c10::ScalarType) const /home/sehoon/pytorch-latest-asan/aten/src/ATen/core/dispatch/Dispatcher.h:521:41
    #23 0x7f7b2bd2aa60 in at::_ops::quantize_per_tensor::call(at::Tensor const&, double, long, c10::ScalarType) /home/sehoon/pytorch-latest-asan/build/aten/src/ATen/Operators_2.cpp:7934:15
    #24 0x7f7b52b1cfdd in at::quantize_per_tensor(at::Tensor const&, double, long, c10::ScalarType) /home/sehoon/pytorch-latest-asan/build/aten/src/ATen/ops/quantize_per_tensor.h:27:12
    #25 0x7f7b52ad9960 in torch::autograd::THPVariable_quantize_per_tensor(_object*, _object*, _object*)::$_316::operator()(at::Tensor const&, double, long, c10::ScalarType) const /home/sehoon/pytorch-latest-asan/torch/csrc/autograd/generated/python_torch_functions_1.cpp:7165:16
    #26 0x7f7b52a34e2a in torch::autograd::THPVariable_quantize_per_tensor(_object*, _object*, _object*) /home/sehoon/pytorch-latest-asan/torch/csrc/autograd/generated/python_torch_functions_1.cpp:7167:19
    #27 0x507386 in cfunction_call /usr/local/src/conda/python-3.9.18/Objects/methodobject.c:543:19

SUMMARY: AddressSanitizer: heap-buffer-overflow /tmp/llvm/utils/release/final/llvm-project/compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp:22:3 in __asan_memcpy
Shadow bytes around the buggy address:
  0x0c127fff7fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c127fff7fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c127fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c127fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c127fff8000: fa fa fa fa fa fa fa fa fd fd fd fd fa fa fa fa
=>0x0c127fff8010: fa fa fa fa fa fa fa fa[04]fa fa fa fa fa fa fa
  0x0c127fff8020: fa fa fa fa fa fa fa fa 04 fa fa fa fa fa fa fa
  0x0c127fff8030: fa fa fa fa fa fa fa fa fd fa fa fa fa fa fa fa
  0x0c127fff8040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c127fff8050: 00 fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c127fff8060: 00 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
==335983==ABORTING
```

### Versions

PyTorch version: 2.2.0a0+git140c54e
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.9.18 (main, Sep 11 2023, 13:41:44)  [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:                      52 bits physical, 57 bits virtual
Byte Order:                         Little Endian
CPU(s):                             112
On-line CPU(s) list:                0-111
Vendor ID:                          GenuineIntel
Model name:                         Intel(R) Xeon(R) Gold 6348 CPU @ 2.60GHz
CPU family:                         6
Model:                              106
Thread(s) per core:                 2
Core(s) per socket:                 28
Socket(s):                          2
Stepping:                           6
CPU max MHz:                        3500.0000
CPU min MHz:                        800.0000
BogoMIPS:                           5200.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 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 invpcid_single ssbd mba ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local split_lock_detect wbnoinvd dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid fsrm md_clear pconfig flush_l1d arch_capabilities
L1d cache:                          2.6 MiB (56 instances)
L1i cache:                          1.8 MiB (56 instances)
L2 cache:                           70 MiB (56 instances)
L3 cache:                           84 MiB (2 instances)
NUMA node(s):                       2
NUMA node0 CPU(s):                  0-27,56-83
NUMA node1 CPU(s):                  28-55,84-111
Vulnerability Gather data sampling: Mitigation; Microcode
Vulnerability Itlb multihit:        Not affected
Vulnerability L1tf:                 Not affected
Vulnerability Mds:                  Not affected
Vulnerability Meltdown:             Not affected
Vulnerability Mmio stale data:      Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Retbleed:             Not affected
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:      Not affected

Versions of relevant libraries:
[pip3] numpy==1.26.2
[pip3] optree==0.10.0
[pip3] torch==2.2.0a0+git140c54e
[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.2.0a0+git140c54e           dev_0    <develop>

cc @jerryzh168 @jianyuh @raghuramank100 @jamesr66a @vkuzo @jgong5 @Xia-Weiwen @leslie-fang-intel @albanD @mruberry @jbschlosser @walterddr @mikaylagawarecki