Skip to content

Conversation

jcaspes
Copy link
Contributor

@jcaspes jcaspes commented Sep 18, 2025

Issue #2913

Under high memory pressure, OutOfMemory exceptions can occure randomly on every line of code that allocate memory like in native Encoding.UTF8.GetString used by the tried call to Format.GetString(span);

Redis value conversion to string should not convert string in hex value on all possible exception but only when value is not a valid UTF8 byte array....

For this the catch will catch only possible exceptions thrown by Encoding.UTF8.GetString, this should not change the conversion behavior but will fix bad results in case of OutOfMemory exceptions or other not expected exceptions.

  • Exception thrown by Encoding.UTF8.GetString from Microsoft documentation:

ArgumentException
The byte array contains invalid Unicode code points.
ArgumentNullException
bytes is null.

DecoderFallbackException
A fallback occurred (for more information, see Character Encoding in .NET)

Has OutOfMemory exceptions can occure in native Encoding.UTF8.GetString, we should not convert result to hex values
@jcaspes jcaspes changed the title Convert to Hex only on Encoding.UTF8.GetString possible exceptions Convert to Hex only on Encoding.UTF8.GetString possible exceptions (#2913) Sep 18, 2025
@jcaspes jcaspes changed the title Convert to Hex only on Encoding.UTF8.GetString possible exceptions (#2913) Convert to Hex only on Encoding.UTF8.GetString possible exceptions Sep 18, 2025
@mgravell
Copy link
Collaborator

Concept looks good

@jcaspes jcaspes marked this pull request as ready for review September 19, 2025 08:21
@jcaspes
Copy link
Contributor Author

jcaspes commented Sep 24, 2025

Hello @mgravell,
The AppVeyor build have failed, i don't know how to relaunch this check.
It seems that there i a problem with build jobs

@mgravell
Copy link
Collaborator

Yes, we're looking into that - unrelated to your PR, don't worry about that.

@mgravell mgravell merged commit 862a70e into StackExchange:main Sep 24, 2025
5 of 6 checks passed
@jcaspes jcaspes deleted the jcaspes/avoid_blob_render_on_OOM branch September 24, 2025 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants