SteNicholas opened a new issue, #456: URL: https://github.com/apache/paimon-cpp/issues/456
### Search before asking - [x] I searched in the [issues](https://github.com/apache/paimon-cpp/issues) and found nothing similar. ### Paimon-cpp version main, commit d21122ecb44f8bc0ffa1eea33a018179ba5b993a ### Minimal reproduce step Log a message with format arguments through the default logger (no custom `LoggerCreator` registered): ```cpp auto logger = paimon::Logger::GetLogger("demo"); PAIMON_LOG_ERROR(logger, "name=%s count=%d", "paimon", 42); ``` ### What doesn't meet your expectations? Expected stderr to contain `name=paimon count=42`. Instead, the arguments come out as garbage. For example, `%s` printed `0` in one run. `GlogAdaptor::LogV` in `src/paimon/common/logging/logging.cpp` passes its `va_list` straight to `google::RawLog__`: ```cpp va_list args; va_start(args, fmt); google::RawLog__(ToGlogLevel(level), fname, lineno, fmt, args); va_end(args); ``` `RawLog__` is a printf-style variadic function (`const char* format, ...`) and has no `va_list` overload. The `va_list` object is therefore passed as a single variadic argument. `%s` reads it as a string pointer, and any later conversions read whatever follows it. This is undefined behavior, so the output depends on the platform. The `GlogForwardingLogger` helper in `src/paimon/common/logging/logging_test.cpp` copies the same pattern. ### Anything else? Proposed fix: expand the arguments with `std::vsnprintf` first, then pass the result to glog through a fixed `"%s"` format: ```cpp char message[4096] = {}; va_list args; va_start(args, fmt); std::vsnprintf(message, sizeof(message), fmt, args); va_end(args); google::RawLog__(ToGlogLevel(level), fname, lineno, "%s", message); ``` This also keeps a literal `%` inside an argument from being read as a format specifier. Add a regression test that captures stderr and checks the formatted message. ### Are you willing to submit a PR? - [x] I'm willing to submit a PR! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
