in_tail: fix offset_key value multiplied by 8 on Windows 64-bit#11893
Conversation
On Win64, FLB_LOG_EVENT_UINT64_VALUE() casts its argument to size_t * (a pointer type) to work around an MSVC varargs type-promotion bug with small constant integers. When the argument is a runtime size_t expression (stream_offset + processed_bytes), MSVC may treat the resulting size_t * differently from a plain uint64_t during varargs passing, causing the received value to be 8x the correct offset. Fix by splitting the combined append_body_values() call into two steps: use the existing FLB_LOG_EVENT_CSTRING_VALUE macro for the key, then call flb_log_event_encoder_append_body_uint64() directly with an explicit (uint64_t) cast for the value. This avoids the variadic path entirely for the numeric offset, eliminating the Win64 MSVC issue. Signed-off-by: zshuang0316 <zshuang0316@163.com>
📝 WalkthroughWalkthroughThe PR refactors how the ChangesOffset key encoding refactor
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
On Win64, FLB_LOG_EVENT_UINT64_VALUE() casts its argument to size_t * (a pointer type) to work around an MSVC varargs type-promotion bug with small constant integers. When the argument is a runtime size_t expression (stream_offset + processed_bytes), MSVC may treat the resulting size_t * differently from a plain uint64_t during varargs passing, causing the received value to be 8x the correct offset.
Fix by splitting the combined append_body_values() call into two steps: use the existing FLB_LOG_EVENT_CSTRING_VALUE macro for the key, then call flb_log_event_encoder_append_body_uint64() directly with an explicit (uint64_t) cast for the value. This avoids the variadic path entirely for the numeric offset, eliminating the Win64 MSVC issue.
Enter
[N/A]in the box, if an item is not applicable to your change.Testing
Before we can approve your change; please submit the following in a comment:
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
ok-package-testlabel to test for all targets (requires maintainer to do).Documentation
Backporting
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.
Summary by CodeRabbit