-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undefined behavior reported with -fsanatize=undefined #166
Comments
Thanks for reporting! I tried I am logging like this : char x[] = "1";
char x2[] = "1234";
uint64_t x3 = 12;
LOG_TRACE_L3(logger, "This is a log trace l3 example {}", x);
LOG_TRACE_L3(logger, "This is a log trace l3 example {}", x2);
LOG_TRACE_L3(logger, "This is a log trace l3 example {}", x3);
LOG_TRACE_L3(logger, "This is a log trace l3 example {} {}", x2, x3);
LOG_TRACE_L3(logger, "This is a log trace l3 example {} {} {}", x, x2, x3); What compiler and what version are you using ? When only build in types are copied, quill just memcpies without aligning the data so I think this could be related to : https://stackoverflow.com/questions/47619944/load-of-misaligned-address-and-ubsan-finding |
This is minimum program which will help you reproduce the behavior. #include <atomic>
#include <cstdint> // for uint64_t
#include <cstdlib>
#include <fstream>
#include <memory> // for allocator, unique_ptr
#include <string> // for string, stoi, getline
#include "quill/Quill.h"
constexpr int kCPUCore = 6;
auto main(int argc, char* argv[]) -> int { // NOLINT(bugprone-exception-escape)
quill::Handler* file_handler = quill::stdout_handler();
file_handler->set_pattern(
QUILL_STRING("%(message)"), // log recorder format
"%H%M%S.%Qms"); // timestamp's format
quill::set_default_logger_handler(file_handler);
quill::config::set_backend_thread_cpu_affinity(kCPUCore);
quill::config::set_backend_thread_name("logger");
quill::start();
std::string env = "debugging";
// NOLINTNEXTLINE
std::atomic_int a = 5;
for (int i = 0; i < 1e6; i++) {
LOG_INFO(quill::get_logger(),
"INFO: debuggin program compiled on {} at {} for "
"Quill UB {}",
__DATE__, __TIME__, env);
std::this_thread::sleep_for(std::chrono::milliseconds(a + 1));
}
return 0;
}
|
Thanks so much for reporting. AddressSanitizer doesn't like the way backend logging thread is reading the buffer header as the data in the buffer is not aligned. This is now fixed in 9e18d25 Another warning due to alignment issue also fixed in e259d15 Closing this, but If you see any more issues please let me know! |
Thanks for the awesome library. I observe these issues only at the start of the program and logggin is not affected. Reporting it here for your information.
<SOME_PATH>/quill/detail/backend/BackendWorker.h:388:28: runtime error: load of misaligned address 0x0210fa900031 for type 'const uint64_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x0210fa900031: note: pointer points here
73 69 6d 00 08 e7 dd 0a 9a e5 2c 00 88 7b 22 70 10 56 00 00 c0 08 41 fa 10 02 00 00 00 00 00 00
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior <SOME_PATH>/quill/detail/backend/BackendWorker.h:388:28 in
<SOME_PATH>/quill/detail/backend/BackendWorker.h:391:45: runtime error: load of misaligned address 0x0210fa900039 for type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x0210fa900039: note: pointer points here
9a e5 2c 00 88 7b 22 70 10 56 00 00 c0 08 41 fa 10 02 00 00 53 86 f5 0a 9a e5 2c 00 f0 79 22 70
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior <SOME_PATH>/quill/detail/backend/BackendWorker.h:391:45 in
<SOME_PATH>/quill/detail/backend/BackendWorker.h:396:37: runtime error: load of misaligned address 0x0210fa900041 for type 'const uintptr_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x0210fa900041: note: pointer points here
10 56 00 00 c0 08 41 fa 10 02 00 00 53 86 f5 0a 9a e5 2c 00 f0 79 22 70 10 56 00 00 80 02 41 fa
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior <SOME_PATH>/quill/detail/backend/BackendWorker.h:396:37 in
The text was updated successfully, but these errors were encountered: