Skip to content

fix(logging): format variadic arguments before forwarding to glog - #457

Merged
lxy-9602 merged 1 commit into
apache:mainfrom
SteNicholas:PAIMON-456
Oct 23, 2026
Merged

lxy-9602 merged 1 commit into
apache:mainfrom
SteNicholas:PAIMON-456

Conversation

@SteNicholas

@SteNicholas SteNicholas commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Purpose

Linked issue: close #456

GlogAdaptor::LogV forwarded a va_list to the printf-style variadic
google::RawLog__, causing undefined behavior and garbled log arguments.

Format the arguments with std::vsnprintf first, then forward the result through
a fixed "%s" format so percent signs in arguments stay literal. The 2048-byte
buffer preserves up to 2047 message bytes and leaves room for glog's raw log prefix.

Tests

Unit tests in src/paimon/common/logging/logging_test.cpp:

  • TestLogFormatsArguments: verifies string/integer substitutions and literal
    percent signs in arguments.
  • TestLogTruncatesLongMessage: verifies complete output at 2047 bytes and
    retention of the first 2047 bytes for an oversized message.
  • TestRegisterCustomLoggerCreator: verifies the factory call count and the
    identity of the returned, pre-created logger in an isolated child process,
    preserving the default logger for shuffled and repeated tests.

Local validation: pre-commit checks for both changed files and git diff --check
passed. C++ tests and clang-tidy were not run locally because the required tools
are unavailable.

API and Format

No public API, storage format, or protocol changes.

Documentation

No documentation changes are required for this bug fix.

Generative AI tooling

Generated-by: Claude Code 2.1.303 (Claude Opus 5.5)

🤖 Generated with Claude Code

@lucasfang lucasfang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Format LogV arguments with std::vsnprintf before forwarding the message
to google::RawLog__ through a fixed "%s" format. Limit the message buffer
to 2048 bytes to leave room for glog's raw log prefix.

Add regression tests for argument formatting and message truncation.
Run custom logger registration in a separate death test process and
return a pre-created logger from the registered factory, verifying its
identity and avoiding duplicate variadic forwarding code in the tests.

@lxy-9602 lxy-9602 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@lxy-9602
lxy-9602 merged commit dc40418 into apache:main Oct 23, 2026
16 checks passed
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.

[Bug] GlogAdaptor::LogV passes va_list to variadic RawLog__, garbling log arguments

3 participants