oneflow icon indicating copy to clipboard operation
oneflow copied to clipboard

Segmentation fault (core dumped) in flow.DoubleTensor

Open deepliao opened this issue 7 months ago • 0 comments

Summary

Creating a DoubleTensor from a Python generator object (generator) causes a segmentation fault in OneFlow. This indicates that the tensor constructor does not validate input types properly. In frameworks like PyTorch or NumPy, such usage raises a TypeError or ValueError, while OneFlow crashes at runtime. This is a serious robustness flaw that may lead to silent crashes and unpredictable behavior in production environments.

Code to reproduce bug

import oneflow as flow
import numpy as np

np.random.seed(42)

# Generator object (not a valid input for tensor creation)
gen = (i for i in range(10))  

# Attempt to construct DoubleTensor from generator
# This leads to segmentation fault
invalid_tensor = flow.DoubleTensor(gen)

output:

Segmentation fault (core dumped)

System Information

OneFlow installation: pip OS: Ubuntu 20.04 OneFlow version (run python3 -m oneflow --doctor):

path: ['/root/miniconda3/envs/myconda/lib/python3.8/site-packages/oneflow']
version: 0.9.0
git_commit: 381b12c
cmake_build_type: Release
rdma: True
mlir: True

Python version: 3.8 CUDA driver version: 11.6 GPU models: NVIDIA A16

deepliao avatar May 11 '25 12:05 deepliao