Skip to content

Fatal Abort with Core Dump on Index Out of Bounds with randperm and Tensor Reshaping #10688

Description

@LiSsHhUuAaIi

Summary

I encountered a fatal program termination with core dump when running a model that should normally throw a catchable IndexError for out-of-bounds indexing. The issue occurs in eager mode when using flow.randperm with tensor reshaping, but instead of raising a proper Python exception that can be handled, OneFlow terminates the entire process with Aborted (core dumped).

Code to reproduce bug

import oneflow as flow
import oneflow.nn as nn

class TestModel(flow.nn.Module):
    def __init__(self):
        super(TestModel, self).__init__()

    def forward(self, x):
        perm = flow.randperm(x.numel())
        x = x.view(-1, 128)
        return x[perm[:64]]

x = flow.randn(32, 128)
model = TestModel()

try:
    # This should raise a catchable IndexError but instead aborts
    result = model(x)
    print("Success:", result)
except Exception as e:
    print("Caught exception:", e)
    print("Program continues normally...")

print("This line should be reachable but isn't due to abort")

Error Logs

terminate called after throwing an instance of 'oneflow::Exception'
  what():  Check failed: (nd_index[i] < dense_shape[i] && nd_index[i] >= -dense_shape[i]) IndexError: index 1495 is out of bounds for dimension 0 with size 32
  ...
  ...
Aborted (core dumped)

System Information

  • OS: Ubuntu 20.04.6 LTS
  • OneFlow version: '1.0.0.dev20251101+cpu'
  • Python version: Python 3.10.19

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions