Skip to content

Segmentation fault occur when using index_copy_ #20322

@Zhaoxian-Wu

Description

@Zhaoxian-Wu

🐛 Bug

When using the index_copy_ function, the programme will throw a segmentation fault.

To Reproduce

Steps to reproduce the behavior:
Run the code below:

import torch
a = torch.randn(3, 5)
c = torch.zeros(3)
a.index_copy_(dim=1, index=torch.tensor([3]), source=c)
MrFive@mrfive-home:~$ python
Python 3.7.2 (default, Dec 29 2018, 06:19:36) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> a = torch.randn(3, 5)
>>> b = torch.zeros(3, 4)
>>> c = torch.zeros(3)
>>> a.index_copy_(dim=1, index=torch.tensor([3]), source=c)
Segmentation fault (core dumped)

I know the code following will work, but it seems that the issue above is an unexpected performent.

a.index_copy_(dim=1, index=torch.tensor([3]), source=c.unsqueeze(1))

Environment

PyTorch version: 1.0.1.post2
Is debug build: No
CUDA used to build PyTorch: None

OS: Ubuntu 18.04.2 LTS
GCC version: (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
CMake version: version 3.10.2

Python version: 3.7
Is CUDA available: No
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA

Versions of relevant libraries:
[pip3] numpy==1.16.2
[conda] blas                      1.0                         mkl    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
[conda] mkl                       2019.1                      144    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
[conda] mkl_fft                   1.0.10           py37ha843d7b_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
[conda] mkl_random                1.0.2            py37hd81dba3_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
[conda] pytorch-cpu               1.0.1               py3.7_cpu_2    pytorch
[conda] torchvision-cpu           0.2.2                      py_3    pytorch

Metadata

Metadata

Assignees

Labels

high prioritymodule: crashProblem manifests as a hard crash, as opposed to a RuntimeErrortriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions