fix(npu): prevent ResourceCleaner timeout overflow on libstdc++ - #142
Open
cabelo wants to merge 2 commits into
Open
fix(npu): prevent ResourceCleaner timeout overflow on libstdc++#142cabelo wants to merge 2 commits into
cabelo wants to merge 2 commits into
Conversation
Contributor
Author
|
@hmaarrfk , @vicamo , @sandraharon and @izelnakri I am an Intel Innovator and the maintainer of the https://news.opensuse.org/2025/12/02/NPU-arrives-in-os-distributions/
I created this PR because of the error below. |
mateusztabaka
approved these changes
Jul 31, 2026
Contributor
Author
|
@mateusztabaka Evidence bellow https://build.opensuse.org/package/show/home:cabelo:intel/linux-npu-driver |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Fixes a crash in the Level Zero NPU driver during initialization on systems using libstdc++ implementations that convert
steady_clockdeadlines internally.Type of change
What does this PR do?
This PR fixes a
SIGABRTthat occurs in theResourceCleanerbackground thread during Level Zero initialization.The cleaner currently uses:
std::chrono::steady_clock::time_point::max()as the deadline passed to:
std::condition_variable::wait_until()On some libstdc++ implementations,
wait_until()converts the suppliedsteady_clockdeadline to another clock by adding the clock offset to the requested time point.Because
time_point::max()is already close to the maximum value of the underlying signed integer representation, this conversion can overflow.When compiled with signed-overflow trapping enabled, the overflow reaches the GCC runtime helper
__addvdi3, which callsabort(). This terminates the entire process withSIGABRT.The observed backtrace was:
The failure occurred while running:
Five of the six initialization tests failed because the child process terminated with status
134, corresponding toSIGABRT.This change avoids passing
time_point::max()towait_until().When no cleanup timeout is active, the cleaner now uses:
When a cleanup timeout is requested, it continues using:
This preserves the existing behavior while avoiding the unsafe clock conversion and integer overflow.
The change also protects updates to
idleTimeoutwith the cleaner mutex, preventing concurrent access betweensetIdleTimeout()and the background cleanup thread.Root cause
The previous implementation used an artificial maximum deadline to represent an infinite wait:
An infinite wait should not be represented by a maximum time point because the standard library may perform clock conversions internally.
Using
condition_variable::wait()is the correct way to wait indefinitely.How did you verify your code works?
The issue was reproduced on:
Before the change:
The failed child processes returned:
GDB confirmed that the process aborted because of a signed integer overflow in the
ResourceCleanerthread.After applying the change:
completed successfully:
The NPU was subsequently detected correctly by OpenVINO:
Result:
Checklist
npu-umd-testChanges
wait_until(time_point::max())call withcondition_variable::wait()wait_until()only when an actual cleanup deadline existsResourceCleanerthread from terminating the process withSIGABRTidleTimeoutusing the existing mutex