Skip to content

Segmentation fault (core dumped) in oneflow.Tensor.__add__(self, other) #10635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
deepliao opened this issue May 11, 2025 · 0 comments
Open
Labels
bug community events from community

Comments

@deepliao
Copy link

Summary

OneFlow does not properly validate data types during tensor arithmetic involving int8 tensors. Specifically, performing an operation like int8_tensor + "a" (string) leads to a segmentation fault, rather than raising a TypeError. This is a severe robustness bug, as such input should never reach the backend and crash the process.

Code to reproduce bug

import oneflow as flow
import numpy as np

# Set fixed seed for reproducibility
np.random.seed(42)

# Create an int8 tensor representing ASCII characters
char_map = [ord(c) for c in "abcdefgh"]
char_tensor = flow.tensor(char_map, dtype=flow.int8)

print(char_tensor)

# Valid operations
char_tensor + 1  
char_tensor + flow.tensor([1], dtype=flow.int8)  
char_tensor * flow.tensor([2], dtype=flow.int8)  
char_tensor.reshape(-1, 2)  
print(char_tensor)

# Invalid operations
# This should raise an exception, not crash
print(char_tensor + 0.5)     # Implicit promotion, should be fine
print(char_tensor + "a")     # ❌ This causes segmentation fault

output:

tensor([ 97,  98,  99, 100, 101, 102, 103, 104], dtype=oneflow.int8)
tensor([ 97,  98,  99, 100, 101, 102, 103, 104], dtype=oneflow.int8)
tensor([ 97.5000,  98.5000,  99.5000, 100.5000, 101.5000, 102.5000, 103.5000, 104.5000], dtype=oneflow.float32)
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 deepliao added bug community events from community labels May 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug community events from community
Projects
None yet
Development

No branches or pull requests

1 participant