oneflow
oneflow copied to clipboard
Segmentation fault (core dumped) in flow.IntTensor
Summary
When attempting to create or fill IntTensor with unsupported data types (e.g., strings or floats), OneFlow does not raise a Python-level error, but instead leads to a segmentation fault (core dumped). This differs from frameworks like PyTorch, which correctly raise type validation exceptions. This is a critical robustness flaw in OneFlow's tensor constructor and input validation, potentially causing silent data corruption or unsafe crashes.
Code to reproduce bug
import oneflow as flow
# Set fixed seed for reproducible behavior
flow.manual_seed(42)
# Example 1: Filling IntTensor with float values
int_tensor = flow.IntTensor([[1, 2], [3, 4]])
print(int_tensor) # Expected: safe output
# This line would raise an error in PyTorch, but may not in OneFlow
# Potential silent downcast or crash
# int_tensor.fill_(3.14)
# Example 2: Initialize IntTensor with non-integer (invalid) type
invalid_type = 'invalid'
try:
int_tensor = flow.IntTensor(invalid_type)
except Exception as e:
print(f"Error during invalid type initialization: {e}")
output:
tensor([[1, 2],
[3, 4]], dtype=oneflow.int32)
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