Skip to content

[#33567] DocDB: Escape non-ASCII bytes in Slice::ToDebugString regardless of locale - #33568

Open
ellabaron-code wants to merge 1 commit into
yugabyte:masterfrom
Shopify:fix-slice-todebugstring-isgraph-locale
Open

[#33567] DocDB: Escape non-ASCII bytes in Slice::ToDebugString regardless of locale#33568
ellabaron-code wants to merge 1 commit into
yugabyte:masterfrom
Shopify:fix-slice-todebugstring-isgraph-locale

Conversation

@ellabaron-code

Copy link
Copy Markdown
Collaborator

Summary

isgraph() is locale-dependent: on macOS in a UTF-8 locale it accepts bytes >= 0xA1, so binary fields rendered via Slice::ToDebugString (e.g. transaction ids in lightweight-protobuf debug output) went into logs as raw unescaped bytes, and the non-graph count often stayed under the --non_graph_characters_percentage_to_use_hexadecimal_rendering threshold. glibc rejects these bytes, so Linux was unaffected.

Evaluate isgraph() in the classic C locale at both call sites so rendering is locale-independent; non-ASCII bytes are always escaped. Linux output is unchanged.

The existing SliceTest.DebugStringLength is extended (and renamed to DebugStringLengthAndLocale) to run under a UTF-8 locale and assert the rendered output contains only printable ASCII — tests run in the default C locale, so without pinning the locale the regression check would pass against the unfixed code.

Fixes #33567

Test plan

  • SliceTest.DebugStringLengthAndLocale fails against the unfixed code on macOS (raw bytes in output) and passes with the fix, on both macOS (arm64) and Linux (x86_64).
  • Verified RemoteBootstrapITest logs on macOS contain no raw binary after the fix (LC_ALL=C grep -rl '[^[:print:][:space:]]' finds nothing); Linux log output unchanged.

On macOS in a UTF-8 locale isgraph() accepts bytes >= 0xA1, so binary
fields (e.g. transaction ids) rendered via ToDebugString went into logs
unescaped. Pin the C locale so non-ASCII bytes are always escaped;
Linux output is unchanged. Extend SliceTest.DebugStringLength to run
under a UTF-8 locale and assert the output contains no raw bytes.
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.

[DocDB] Slice::ToDebugString writes unescaped binary to logs on macOS in UTF-8 locales

2 participants