Fix more Valgrind uninitialized value errors

1. MySQL_Logger.cpp: Initialize username_len, schemaname_len, and server_len
   to 0 in MySQL_Event constructor. These fields were uninitialized and
   used in copy constructor and JSON serialization.

2. debug.cpp: Add default member initializers to DebugLogEntry struct
   to ensure POD fields are zero-initialized. Move errno save/restore
   to after early return checks to avoid potential TLS access issues
   before thread is fully initialized.
v3.0-test0213
Rene Cannao 6 days ago
parent ee7ee0b387
commit c2f82b3d4e

@ -353,6 +353,8 @@ MySQL_Event::MySQL_Event (log_event_type _et, uint32_t _thread_id, char * _usern
thread_id=_thread_id;
username=_username;
schemaname=_schemaname;
username_len=0;
schemaname_len=0;
start_time=_start_time;
end_time=_end_time;
query_digest=_query_digest;
@ -361,6 +363,7 @@ MySQL_Event::MySQL_Event (log_event_type _et, uint32_t _thread_id, char * _usern
et=_et;
hid=UINT64_MAX;
server=NULL;
server_len=0;
extra_info = NULL;
have_affected_rows=false;
affected_rows=0;

@ -31,15 +31,15 @@ static unsigned int debug_output = 1;
struct DebugLogEntry {
unsigned long long time;
unsigned long long lapse;
int thr;
unsigned long long time = 0;
unsigned long long lapse = 0;
int thr = 0;
std::string file;
int line;
int line = 0;
std::string funct;
int module;
int module = 0;
std::string modname;
int verbosity;
int verbosity = 0;
std::string message;
std::string backtrace;
};
@ -178,20 +178,19 @@ void proxy_debug_func(
const char *fmt,
...
) {
int saved_errno = errno;
assert(module<PROXY_DEBUG_UNKNOWN);
// Safety check: ensure debug struct is initialized
if (GloVars.global.gdbg_lvl == NULL) {
errno = saved_errno;
return;
}
if (pretime == 0) { // never initialized
pretime=realtime_time();
}
if (GloVars.global.gdbg_lvl[module].verbosity < verbosity) {
errno = saved_errno;
return;
}
// Save errno only after passing early return checks
int saved_errno = errno;
// check if the entry must be filtered
if (filter_debug_entry(__file, __line, __func)) {
errno = saved_errno;

Loading…
Cancel
Save