Repository: pytorch
Issue: LibTorch, Error in 'xxx': free(): invalid pointer
Labels: needs reproduction,module: cpp,triaged

## 🐛 Bug

Hi, maybe I found a bug in LibTorch while run codes in CentOS, the codes are very simplify. I have try it in 2 CentOS Machines and 1 Ubuntu Machine, Ubuntu Machine can run it normally, but all of the CentOS Machines run it like follow outputs.

## To Reproduce

Steps to reproduce the behavior:

1. download libtorch and unzip
2. compile the cpp file
3. run

Here are the codes:
```c++
#include<iostream>
#include<torch/torch.h>
#include <torch/script.h>

int main() {
	torch::Tensor a = torch::ones({2,4});
	std::cout << a << std::endl;
	return 0;
}
```

Here is the CMakeList:
```cmake
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(tr)

find_package(Torch REQUIRED)
aux_source_directory(. SRC_LIST)
add_executable(test ${SRC_LIST})
set(CMAKE_CXX_STANDARD 11)
target_link_libraries(test "${TORCH_LIBRARIES}")
set_property(TARGET test PROPERTY CXX_STANDARD 11)
```

Here is the output:
```
 1  1  1  1
 1  1  1  1
[ Variable[CPUFloatType]{2,4} ]
*** Error in `./test': free(): invalid pointer: 0x00007f040f871090 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x81679)[0x7f04022b3679]
./test(_ZN9__gnu_cxx13new_allocatorIPNSt8__detail15_Hash_node_baseEE10deallocateEPS3_m+0x20)[0x41fd0e]
./test(_ZNSt10_HashtableISsSt4pairIKSsSsESaIS2_ENSt8__detail10_Select1stESt8equal_toISsESt4hashISsENS4_18_Mod_range_hashingENS4_20_Default_ranged_hashENS4_20_Prime_rehash_policyENS4_17_Hashtable_traitsILb1ELb0ELb1EEEE21_M_deallocate_bucketsEPPNS4_15_Hash_node_baseEm+0x49)[0x41f20f]
./test(_ZNSt10_HashtableISsSt4pairIKSsSsESaIS2_ENSt8__detail10_Select1stESt8equal_toISsESt4hashISsENS4_18_Mod_range_hashingENS4_20_Default_ranged_hashENS4_20_Prime_rehash_policyENS4_17_Hashtable_traitsILb1ELb0ELb1EEEED1Ev+0x36)[0x41df10]
/lib64/libc.so.6(__cxa_finalize+0x9a)[0x7f040226c00a]
/home/yyuser/nlp/codes/bd-nlp/libtorch/lib/libtorch.so(+0x9fa9d3)[0x7f040367e9d3]
======= Memory map: ========
00400000-00429000 r-xp 00000000 fd:02 186000054                          /home/yyuser/nlp/codes/bd-nlp/tr/alg-service/build/test
00628000-00629000 r--p 00028000 fd:02 186000054                          /home/yyuser/nlp/codes/bd-nlp/tr/alg-service/build/test
00629000-0062a000 rw-p 00029000 fd:02 186000054                          /home/yyuser/nlp/codes/bd-nlp/tr/alg-service/build/test
021b1000-02aee000 rw-p 00000000 00:00 0                                  [heap]
7f03fc000000-7f03fc021000 rw-p 00000000 00:00 0 
7f03fc021000-7f0400000000 ---p 00000000 00:00 0 
7f04018fa000-7f04019fb000 r-xp 00000000 fd:02 1548                       /usr/lib64/libm-2.17.so
7f04019fb000-7f0401bfa000 ---p 00101000 fd:02 1548                       /usr/lib64/libm-2.17.so
7f0401bfa000-7f0401bfb000 r--p 00100000 fd:02 1548                       /usr/lib64/libm-2.17.so
7f0401bfb000-7f0401bfc000 rw-p 00101000 fd:02 1548                       /usr/lib64/libm-2.17.so
7f0401bfc000-7f0401bfe000 r-xp 00000000 fd:02 1546                       /usr/lib64/libdl-2.17.so
7f0401bfe000-7f0401dfe000 ---p 00002000 fd:02 1546                       /usr/lib64/libdl-2.17.so
7f0401dfe000-7f0401dff000 r--p 00002000 fd:02 1546                       /usr/lib64/libdl-2.17.so
7f0401dff000-7f0401e00000 rw-p 00003000 fd:02 1546                       /usr/lib64/libdl-2.17.so
7f0401e00000-7f0401e07000 r-xp 00000000 fd:02 1570                       /usr/lib64/librt-2.17.so
7f0401e07000-7f0402006000 ---p 00007000 fd:02 1570                       /usr/lib64/librt-2.17.so
7f0402006000-7f0402007000 r--p 00006000 fd:02 1570                       /usr/lib64/librt-2.17.so
7f0402007000-7f0402008000 rw-p 00007000 fd:02 1570                       /usr/lib64/librt-2.17.so
7f0402008000-7f040202d000 r-xp 00000000 fd:02 352611484                  /home/yyuser/nlp/codes/bd-nlp/libtorch/lib/libgomp-7c85b1e2.so.1
7f040202d000-7f040222c000 ---p 00025000 fd:02 352611484                  /home/yyuser/nlp/codes/bd-nlp/libtorch/lib/libgomp-7c85b1e2.so.1
7f040222c000-7f040222d000 r--p 00024000 fd:02 352611484                  /home/yyuser/nlp/codes/bd-nlp/libtorch/lib/libgomp-7c85b1e2.so.1
7f040222d000-7f0402232000 rw-p 00025000 fd:02 352611484                  /home/yyuser/nlp/codes/bd-nlp/libtorch/lib/libgomp-7c85b1e2.so.1
7f0402232000-7f04023f5000 r-xp 00000000 fd:02 1540                       /usr/lib64/libc-2.17.so
7f04023f5000-7f04025f5000 ---p 001c3000 fd:02 1540                       /usr/lib64/libc-2.17.so
7f04025f5000-7f04025f9000 r--p 001c3000 fd:02 1540                       /usr/lib64/libc-2.17.so
7f04025f9000-7f04025fb000 rw-p 001c7000 fd:02 1540                       /usr/lib64/libc-2.17.so
7f04025fb000-7f0402600000 rw-p 00000000 00:00 0 
7f0402600000-7f0402615000 r-xp 00000000 fd:02 1311741                    /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7f0402615000-7f0402814000 ---p 00015000 fd:02 1311741                    /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7f0402814000-7f0402815000 r--p 00014000 fd:02 1311741                    /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7f0402815000-7f0402816000 rw-p 00015000 fd:02 1311741                    /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7f0402816000-7f040282d000 r-xp 00000000 fd:02 1566                       /usr/lib64/libpthread-2.17.so
7f040282d000-7f0402a2c000 ---p 00017000 fd:02 1566                       /usr/lib64/libpthread-2.17.so
7f0402a2c000-7f0402a2d000 r--p 00016000 fd:02 1566                       /usr/lib64/libpthread-2.17.so
7f0402a2d000-7f0402a2e000 rw-p 00017000 fd:02 1566                       /usr/lib64/libpthread-2.17.so
7f0402a2e000-7f0402a32000 rw-p 00000000 00:00 0 
7f0402a32000-7f0402a77000 r-xp 00000000 fd:02 352611503                  /home/yyuser/nlp/codes/bd-nlp/libtorch/lib/libc10.so
7f0402a77000-7f0402c77000 ---p 00045000 fd:02 352611503                  /home/yyuser/nlp/codes/bd-nlp/libtorch/lib/libc10.so
7f0402c77000-7f0402c78000 r--p 00045000 fd:02 352611503                  /home/yyuser/nlp/codes/bd-nlp/libtorch/lib/libc10.so
7f0402c78000-7f0402c79000 rw-p 00046000 fd:02 352611503                  /home/yyuser/nlp/codes/bd-nlp/libtorch/lib/libc10.so
7f0402c79000-7f0402c7a000 rw-p 00000000 00:00 0 
7f0402c7a000-7f0402c84000 rw-p 0005f000 fd:02 352611503                  /home/yyuser/nlp/codes/bd-nlp/libtorch/lib/libc10.so
7f0402c84000-7f040f47f000 r-xp 00000000 fd:02 352611487                  /home/yyuser/nlp/codes/bd-nlp/libtorch/lib/libtorch.so
7f040f47f000-7f040f67f000 ---p 0c7fb000 fd:02 352611487                  /home/yyuser/nlp/codes/bd-nlp/libtorch/lib/libtorch.so
7f040f67f000-7f040f75d000 r--p 0c7fb000 fd:02 352611487                  /home/yyuser/nlp/codes/bd-nlp/libtorch/lib/libtorch.so
7f040f75d000-7f040f854000 rw-p 0c8d9000 fd:02 352611487                  /home/yyuser/nlp/codes/bd-nlp/libtorch/lib/libtorch.so
7f040f854000-7f040f8a6000 rw-p 00000000 00:00 0 
7f040f8a6000-7f040fb5e000 rw-p 0db6f000 fd:02 352611487                  /home/yyuser/nlp/codes/bd-nlp/libtorch/lib/libtorch.so
7f040fb5e000-7f040fb80000 r-xp 00000000 fd:02 1533                       /usr/lib64/ld-2.17.so
7f040fbe9000-7f040fbff000 rw-p 00000000 00:00 0 
7f040fbff000-7f040fca1000 r--p 00000000 fd:02 9122949                    /usr/lib/libstdc++.so.6.0.26
7f040fca1000-7f040fd20000 r-xp 000a2000 fd:02 9122949                    /usr/lib/libstdc++.so.6.0.26
7f040fd20000-7f040fd61000 r--p 00121000 fd:02 9122949                    /usr/lib/libstdc++.so.6.0.26[1]    14117 abort      ./test
```


## Environment


 - PyTorch Version (e.g., 1.0): 1.3
 - OS (e.g., Linux): CentOS Linux release 7.7.1908 (Core) and CentOS Linux release 7.6.1810 (Core) 
 - How you installed PyTorch (`conda`, `pip`, source): LibTorch(Pre-cxx11 ABI)
 - CUDA/cuDNN version: no GPU
 - LibTorch download url: [https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-1.3.1%2Bcpu.zip](https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-1.3.1%2Bcpu.zip)



cc @ezyang @gchanan @zou3519 @jerryzh168 @yf225