Skip to content

Segmentation fault when dividing by zero with integer tensors #327

@fmassa

Description

@fmassa

This seems to be an issue with TH and not pytorch, the same thing happens in lua torch.

import torch
a = torch.IntTensor([0,1])
b = torch.IntTensor([0,1])
print(a.div(b)) # Floating point exception (core dumped)

Another unrelated weirdness happens with float tensors when the answer is inf

import torch
a = torch.FloatTensor([1,1])
b = torch.FloatTensor([0,0])
a.div(b)

which works on lua torch, but gives

<repr(<torch.FloatTensor at 0x7f8a012eee18>) failed: RuntimeError: inconsistent tensor size at /tmp/pip-zh0a53-build/torch/lib/TH/generic/THTensorMath.c:90>

in pytorch.

cc @ezyang @gchanan @zou3519

Metadata

Metadata

Assignees

Labels

high prioritymodule: NaNs and InfsProblems related to NaN and Inf handling in floating pointmodule: 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