Fix uninitialized memory in Command_Counter::_counters

Replace _counters{} initialization syntax with explicit memset() to ensure
the _counters array is properly zero-initialized. The _counters{} syntax
may not reliably zero-initialize arrays in all compiler implementations,
causing Valgrind to report use of uninitialized values when
add_and_reset() reads from the array.

Also remove the safety checks added previously since the root cause
is now properly fixed.
v3.0-test0213
Rene Cannao 6 days ago
parent c2f82b3d4e
commit fdbea2a32e

@ -3,10 +3,9 @@
class Command_Counter {
public:
Command_Counter(int cmd_idx, int col_count, char** cmd_desc) : _counters{}, _total_time(0), _cmd_idx(cmd_idx),
Command_Counter(int cmd_idx, int col_count, char** cmd_desc) : _total_time(0), _cmd_idx(cmd_idx),
_col_count(col_count), _cmd_desc(cmd_desc) {
//memset(_counters, 0, sizeof(_counters));
memset(_counters, 0, sizeof(_counters));
}
void add_and_reset(Command_Counter* cc) {
for (int j = 0; j < static_cast<int>(sizeof(_counters)/sizeof(_counters[0])); j++) {

@ -245,7 +245,9 @@ PgSQL_Query_Processor::~PgSQL_Query_Processor() {
void PgSQL_Query_Processor::update_query_processor_stats() {
Query_Processor::update_query_processor_stats();
for (int i = 0; i < PGSQL_QUERY___NONE; i++) commands_counters[i]->add_and_reset(_thr_commands_counters[i]);
for (int i = 0; i < PGSQL_QUERY___NONE; i++) {
commands_counters[i]->add_and_reset(_thr_commands_counters[i]);
}
}
void PgSQL_Query_Processor::init_thread() {

Loading…
Cancel
Save