Provide more accurate error codes for busy-loop scenarios #3455
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.
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