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

Provide more accurate error codes for busy-loop scenarios #3455

Merged
merged 1 commit into from
Jan 25, 2023
Merged

Conversation

Cyan4973
Copy link
Contributor

@Cyan4973 Cyan4973 commented Jan 25, 2023

In a busy-loop scenario, the user process calls a libzstd streaming function in a loop,
but no work gets ever done, due to some external condition.
For example there is no input to process,
or the output buffer is already full and cannot accept another byte.

These scenarios are considered programming errors. When there is no forward progress, the program can continuously call libzstd in a (potentially infinite) busy loop, cramming away cpu resources and power supply. The caller should not continuously present an empty input (it should wait for some bytes to process), nor an already full destination buffer (it should be flushed first).

To avoid this outcome, libzstd returns an error code after too many function calls with no forward progress happened.

#3454 notes that the corresponding error codes can be difficult to interpret, because they are not specific enough.
This PR adds 2 new error codes, employed specifically for these noForwardProgress scenarios, so that the root cause of the error can be more easily identified.

fixes #3454

@Cyan4973 Cyan4973 merged commit efc9ae3 into dev Jan 25, 2023
@Cyan4973 Cyan4973 deleted the fix3454 branch January 26, 2023 22:44
@Cyan4973 Cyan4973 mentioned this pull request Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ZSTD_NO_FORWARD_PROGRESS_MAX case should give more explicit error
3 participants