Skip to content
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

SafeIntOnOverflow() Integer overflow error when inferencing on too many samples with Python #18905

Open
jacktwosense opened this issue Dec 21, 2023 · 1 comment
Labels
core runtime issues related to core runtime

Comments

@jacktwosense
Copy link

Describe the issue

When inferencing with too many samples in Python, I get this error on Ubuntu:
[E:onnxruntime:Default, allocator.cc:36 operator()] /onnxruntime_src/onnxruntime/core/common/safeint.h:17 static void SafeIntExceptionHandler<onnxruntime::OnnxRuntimeException>::SafeIntOnOverflow() Integer overflow

When running the same script on an M1 Mac, it appears as a SIGABRT with libc++abi terminating message.

I'm able to mitigate this by inferencing in batches and concatenating the results.

To reproduce

Inference with a large number of samples (low millions?). Maybe > 32767 is sufficient, since that's the max for int16, but I haven't verified that.

Urgency

No response

Platform

Linux

OS Version

Ubuntu

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

1.16.3

ONNX Runtime API

Python

Architecture

X64

Execution Provider

Default CPU

Execution Provider Library Version

No response

@yf711 yf711 added the core runtime issues related to core runtime label Dec 22, 2023
@skottmckay
Copy link
Contributor

Are you able to share a model that this occurs with?

skottmckay added a commit that referenced this issue Dec 27, 2023
…y return a nullptr. This is inconsistent as an actual memory allocation failure throws. An overflow would typically be due to bad input so an exception makes more sense given that.

Change to throw so code using MakeUniquePtr* and AllocArray* doesn't need to check for nullptr.

Add some extra info to the log message to help debugging.

Should help with #18905 by avoiding the invalid attempted usage of a nullptr from the allocation. Extra info _might_ help with figuring out where the overflow is coming from which is the real issue.
skottmckay added a commit that referenced this issue Jan 2, 2024
…#18941)

### Description
<!-- Describe your changes. -->
If we fail to calculate the buffer size (due to overflow) we currently
return a nullptr. This is inconsistent as an actual memory allocation
failure throws. An overflow would typically be due to bad input so an
exception makes more sense given that.

Change to throw so code using MakeUniquePtr* and AllocArray* doesn't
need to check for nullptr.

Add some extra info to the log message to help debugging.

### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->
Should help with #18905 by avoiding the invalid attempted usage of a
nullptr from the allocation. Extra info _might_ help with figuring out
where the overflow is coming from which is the real issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core runtime issues related to core runtime
Projects
None yet
Development

No branches or pull requests

3 participants