From ff88db7e4ade531a162078815c54e42085417c0a Mon Sep 17 00:00:00 2001 From: Anshu6250 Date: Thu, 16 Jul 2026 18:47:34 +0530 Subject: [PATCH 1/4] test with main --- .../odbc/integration_tests/odbc_driver_tests/statement_test.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/google/cloud/odbc/integration_tests/odbc_driver_tests/statement_test.cc b/google/cloud/odbc/integration_tests/odbc_driver_tests/statement_test.cc index ba0134cc10..ee6a76948b 100644 --- a/google/cloud/odbc/integration_tests/odbc_driver_tests/statement_test.cc +++ b/google/cloud/odbc/integration_tests/odbc_driver_tests/statement_test.cc @@ -4292,6 +4292,7 @@ TEST(SQLMoreResults, ProcedureWithDescriptorAndQueryParams) { status = SQLPrepare(conn->hstmt, (SQLCHAR*)call_proc.c_str(), SQL_NTS); CheckError(status, "SQLPrepare (call procedure)", conn); + // Bind parameters SQLCHAR str_val[] = "Test String 5"; SQLLEN str_ind = SQL_NTS; From bfe76f74849c97761e595c0f4ecdf25d9a3e1e35 Mon Sep 17 00:00:00 2001 From: Anshu6250 Date: Fri, 17 Jul 2026 00:58:00 +0530 Subject: [PATCH 2/4] test --- .../cloud/odbc/bq_driver/internal/trace_utils.cc | 12 ++++++------ .../cloud/odbc/bq_driver/internal/trace_utils.h | 16 ++++++++++++---- google/cloud/odbc/bq_driver/odbc_connection.cc | 6 +++--- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/google/cloud/odbc/bq_driver/internal/trace_utils.cc b/google/cloud/odbc/bq_driver/internal/trace_utils.cc index 9d9ee8aded..7506e245ed 100644 --- a/google/cloud/odbc/bq_driver/internal/trace_utils.cc +++ b/google/cloud/odbc/bq_driver/internal/trace_utils.cc @@ -161,11 +161,11 @@ void UpdateTraceOption(std::optional log_level, std::optional log_file_size, std::optional log_file_count, std::optional max_threads) { - if (!kTraceOptsFile.Ok() || !(log_level || log_path || log_file_size || + if (!GetTraceOptsFile().Ok() || !(log_level || log_path || log_file_size || log_file_count || max_threads)) return; - auto const& trace_options = kTraceOptsFile.GetValue(); + auto const& trace_options = GetTraceOptsFile().GetValue(); std::lock_guard lock(trace_options->m); if (log_level) { @@ -186,8 +186,8 @@ std::string GetLogFileWithIndex(std::string const& log_path) { std::string base_dir = log_path; int file_index = 0; - if (kTraceOptsFile.Ok()) { - auto const& trace_opts = kTraceOptsFile.GetValue(); + if (GetTraceOptsFile().Ok()) { + auto const& trace_opts = GetTraceOptsFile().GetValue(); file_index = trace_opts->current_file_index; } std::string separator = @@ -216,8 +216,8 @@ bool TraceOptions::InitializeLogging(bool is_trace_override) { std::call_once(absl_log_init_flag, []() { absl::InitializeLog(); }); absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfinity); - if (!kTraceOptsFile.Ok()) return false; - auto const& trace_opts = kTraceOptsFile.GetValue(); + if (!GetTraceOptsFile().Ok()) return false; + auto const& trace_opts = GetTraceOptsFile().GetValue(); // If logging is disabled, return false if (trace_opts->log_level <= 0) { diff --git a/google/cloud/odbc/bq_driver/internal/trace_utils.h b/google/cloud/odbc/bq_driver/internal/trace_utils.h index 6124b12495..6df1e145ed 100644 --- a/google/cloud/odbc/bq_driver/internal/trace_utils.h +++ b/google/cloud/odbc/bq_driver/internal/trace_utils.h @@ -189,10 +189,18 @@ std::string GetFormattedMsg(absl::LogEntry const& entry); // Struct types. ///////////////////////////////////////////// -static odbc_internal::StatusRecordOr> const - kTraceOptsFile = - TraceOptions::CreateTraceOptionsFile(GetOdbcTraceConfigPath()); +// Returns the singleton TraceOptions instance, lazily initialized on first +// use. This avoids the static initialization order fiasco and prevents +// abseil flat_hash_map corruption that can occur when kTraceOptsFile was +// previously a static variable in a header file (which caused each +// translation unit to have its own copy and resulted in ASAN assertion +// failures). +inline auto const& GetTraceOptsFile() { + static auto const kTraceOptsFile = + TraceOptions::CreateTraceOptionsFile(GetOdbcTraceConfigPath()); + return kTraceOptsFile; +} } // namespace google::cloud::odbc_bq_driver_internal -#endif // CPP_BIGQUERY_ODBC_GOOGLE_CLOUD_ODBC_BQ_DRIVER_INTERNAL_TRACE_UTILS_H +#endif // CPP_BIGQUERY_ODBC_GOOGLE_CLOUD_ODBC_BQ_DRIVER_INTERNAL_TRACE_UTILS_H \ No newline at end of file diff --git a/google/cloud/odbc/bq_driver/odbc_connection.cc b/google/cloud/odbc/bq_driver/odbc_connection.cc index 96646b9efa..f14993712f 100644 --- a/google/cloud/odbc/bq_driver/odbc_connection.cc +++ b/google/cloud/odbc/bq_driver/odbc_connection.cc @@ -39,7 +39,7 @@ using google::cloud::odbc_bq_driver_internal::EnvironmentHandle; using google::cloud::odbc_bq_driver_internal::GetDefaultPemFile; using google::cloud::odbc_bq_driver_internal::GetMissingAttributesStr; using google::cloud::odbc_bq_driver_internal::GetUpperStr; -using google::cloud::odbc_bq_driver_internal::kTraceOptsFile; +using google::cloud::odbc_bq_driver_internal::GetTraceOptsFile; using google::cloud::odbc_bq_driver_internal::LogAndReturnCode; using google::cloud::odbc_bq_driver_internal::PopulateOutputConnectionString; using google::cloud::odbc_bq_driver_internal::Section; @@ -323,8 +323,8 @@ SQLRETURN SQLDriverConnectInternal(SQLHDBC conn_handle, SQLHWND window_handle, dsn_section[property] = it.second; } } - if (kTraceOptsFile.Ok()) { - auto const& trace_options = kTraceOptsFile.GetValue(); + if (GetTraceOptsFile().Ok()) { + auto const& trace_options = GetTraceOptsFile().GetValue(); if (!trace_options->logging_enabled) { config_res = ConfigTraceFromSection(dsn_section); } From b089b246e3f333c8ddd3cd274254cc245d7ce345 Mon Sep 17 00:00:00 2001 From: Anshu6250 Date: Mon, 20 Jul 2026 13:15:13 +0530 Subject: [PATCH 3/4] test --- .../cloud/odbc/bq_driver/internal/trace_utils.cc | 15 +++++++++------ .../cloud/odbc/bq_driver/internal/trace_utils.h | 2 +- google/cloud/odbc/bq_driver/odbc_connection.cc | 5 +++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/google/cloud/odbc/bq_driver/internal/trace_utils.cc b/google/cloud/odbc/bq_driver/internal/trace_utils.cc index 7506e245ed..3e9795e25a 100644 --- a/google/cloud/odbc/bq_driver/internal/trace_utils.cc +++ b/google/cloud/odbc/bq_driver/internal/trace_utils.cc @@ -161,11 +161,12 @@ void UpdateTraceOption(std::optional log_level, std::optional log_file_size, std::optional log_file_count, std::optional max_threads) { - if (!GetTraceOptsFile().Ok() || !(log_level || log_path || log_file_size || + auto trace_opts = GetTraceOptsFile(); + if (!trace_opts.Ok() || !(log_level || log_path || log_file_size || log_file_count || max_threads)) return; - auto const& trace_options = GetTraceOptsFile().GetValue(); + auto const& trace_options = trace_opts.GetValue(); std::lock_guard lock(trace_options->m); if (log_level) { @@ -186,8 +187,9 @@ std::string GetLogFileWithIndex(std::string const& log_path) { std::string base_dir = log_path; int file_index = 0; - if (GetTraceOptsFile().Ok()) { - auto const& trace_opts = GetTraceOptsFile().GetValue(); + auto trace_opts_file = GetTraceOptsFile(); + if (trace_opts_file.Ok()) { + auto const& trace_opts = trace_opts_file.GetValue(); file_index = trace_opts->current_file_index; } std::string separator = @@ -216,8 +218,9 @@ bool TraceOptions::InitializeLogging(bool is_trace_override) { std::call_once(absl_log_init_flag, []() { absl::InitializeLog(); }); absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfinity); - if (!GetTraceOptsFile().Ok()) return false; - auto const& trace_opts = GetTraceOptsFile().GetValue(); + auto trace_opts_file = GetTraceOptsFile(); + if (!trace_opts_file.Ok()) return false; + auto const& trace_opts = trace_opts_file.GetValue(); // If logging is disabled, return false if (trace_opts->log_level <= 0) { diff --git a/google/cloud/odbc/bq_driver/internal/trace_utils.h b/google/cloud/odbc/bq_driver/internal/trace_utils.h index 6df1e145ed..ba1dd547a0 100644 --- a/google/cloud/odbc/bq_driver/internal/trace_utils.h +++ b/google/cloud/odbc/bq_driver/internal/trace_utils.h @@ -195,7 +195,7 @@ std::string GetFormattedMsg(absl::LogEntry const& entry); // previously a static variable in a header file (which caused each // translation unit to have its own copy and resulted in ASAN assertion // failures). -inline auto const& GetTraceOptsFile() { +inline auto GetTraceOptsFile() { static auto const kTraceOptsFile = TraceOptions::CreateTraceOptionsFile(GetOdbcTraceConfigPath()); return kTraceOptsFile; diff --git a/google/cloud/odbc/bq_driver/odbc_connection.cc b/google/cloud/odbc/bq_driver/odbc_connection.cc index f14993712f..a29128f5f0 100644 --- a/google/cloud/odbc/bq_driver/odbc_connection.cc +++ b/google/cloud/odbc/bq_driver/odbc_connection.cc @@ -323,8 +323,9 @@ SQLRETURN SQLDriverConnectInternal(SQLHDBC conn_handle, SQLHWND window_handle, dsn_section[property] = it.second; } } - if (GetTraceOptsFile().Ok()) { - auto const& trace_options = GetTraceOptsFile().GetValue(); + auto trace_opts_file = GetTraceOptsFile(); + if (trace_opts_file.Ok()) { + auto const& trace_options = trace_opts_file.GetValue(); if (!trace_options->logging_enabled) { config_res = ConfigTraceFromSection(dsn_section); } From d8696e44187cef47161424b8294a9122edff7c21 Mon Sep 17 00:00:00 2001 From: Anshu6250 Date: Mon, 20 Jul 2026 15:41:27 +0530 Subject: [PATCH 4/4] test --- google/cloud/odbc/bq_driver/internal/trace_utils.cc | 11 +++++++++++ google/cloud/odbc/bq_driver/internal/trace_utils.h | 6 +----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/google/cloud/odbc/bq_driver/internal/trace_utils.cc b/google/cloud/odbc/bq_driver/internal/trace_utils.cc index 3e9795e25a..b6ca4675f0 100644 --- a/google/cloud/odbc/bq_driver/internal/trace_utils.cc +++ b/google/cloud/odbc/bq_driver/internal/trace_utils.cc @@ -315,4 +315,15 @@ std::shared_ptr TraceOptions::GetTraceOption() { return options_file_; } +// Returns the singleton TraceOptions instance, lazily initialized on first +// use. This avoids the static initialization order fiasco and prevents +// abseil flat_hash_map corruption that can occur when this was previously +// an inline function in a header file (which caused each translation unit +// to have its own copy and resulted in ASAN assertion failures). +odbc_internal::StatusRecordOr> GetTraceOptsFile() { + static auto const kTraceOptsFile = + TraceOptions::CreateTraceOptionsFile(GetOdbcTraceConfigPath()); + return kTraceOptsFile; +} + } // namespace google::cloud::odbc_bq_driver_internal diff --git a/google/cloud/odbc/bq_driver/internal/trace_utils.h b/google/cloud/odbc/bq_driver/internal/trace_utils.h index ba1dd547a0..1de3766056 100644 --- a/google/cloud/odbc/bq_driver/internal/trace_utils.h +++ b/google/cloud/odbc/bq_driver/internal/trace_utils.h @@ -195,11 +195,7 @@ std::string GetFormattedMsg(absl::LogEntry const& entry); // previously a static variable in a header file (which caused each // translation unit to have its own copy and resulted in ASAN assertion // failures). -inline auto GetTraceOptsFile() { - static auto const kTraceOptsFile = - TraceOptions::CreateTraceOptionsFile(GetOdbcTraceConfigPath()); - return kTraceOptsFile; -} +odbc_internal::StatusRecordOr> GetTraceOptsFile(); } // namespace google::cloud::odbc_bq_driver_internal