diff --git a/eng/pipelines/templates/jobs/archetype-sdk-tests.yml b/eng/pipelines/templates/jobs/archetype-sdk-tests.yml index 023430caa..10a34f838 100644 --- a/eng/pipelines/templates/jobs/archetype-sdk-tests.yml +++ b/eng/pipelines/templates/jobs/archetype-sdk-tests.yml @@ -146,7 +146,7 @@ jobs: CmakeEnvArg: "" CmakeArgs: "" AZURE_TEST_MODE: "LIVE" - #AZURE_LOG_LEVEL: "verbose" + AZURE_LOG_LEVEL: "verbose" steps: - checkout: self diff --git a/eng/pipelines/templates/jobs/ci.tests.yml b/eng/pipelines/templates/jobs/ci.tests.yml index 80f3dcf80..a6814599e 100644 --- a/eng/pipelines/templates/jobs/ci.tests.yml +++ b/eng/pipelines/templates/jobs/ci.tests.yml @@ -70,6 +70,8 @@ jobs: # Apply to all services running public pipeline - name: AZURE_TEST_MODE value: "PLAYBACK" + - name: AZURE_LOG_LEVEL + value: "verbose" - ${{ each testEnvVar in parameters.TestEnv }}: - name: ${{ testEnvVar.Name }} value: ${{ testEnvVar.Value }} diff --git a/sdk/core/azure-core/CHANGELOG.md b/sdk/core/azure-core/CHANGELOG.md index 889a59f78..e07882b94 100644 --- a/sdk/core/azure-core/CHANGELOG.md +++ b/sdk/core/azure-core/CHANGELOG.md @@ -12,6 +12,8 @@ - Fixed `Azure::DateTime::Parse()` validation if the result is going to exceed `9999-12-31T23:59:59.9999999` due to time zone, leap second, or fractional digits rounding up adjustments. +- [[#3224]](https://github.com/Azure/azure-sdk-for-cpp/issues/3224) Fixed intermittent crash on macOS when logging is turned on. + ### Other Changes ## 1.3.1 (2021-11-05) diff --git a/sdk/core/azure-core/src/http/curl/curl.cpp b/sdk/core/azure-core/src/http/curl/curl.cpp index 1e27d43c6..2c9d58f18 100644 --- a/sdk/core/azure-core/src/http/curl/curl.cpp +++ b/sdk/core/azure-core/src/http/curl/curl.cpp @@ -188,14 +188,17 @@ static inline std::string GetHTTPMessagePreBody(Azure::Core::Http::Request const static void CleanupThread() { + // NOTE: Avoid using Log::Write in here as it may fail on macOS, + // see issue: https://github.com/Azure/azure-sdk-for-cpp/issues/3224 + // This method can wake up in de-attached mode after the application has been terminated. + // If that happens, trying to use `Log` would cause `abort` as it was previously deallocated. using namespace Azure::Core::Http::_detail; for (;;) { - Log::Write(Logger::Level::Verbose, "Clean pool check now..."); // Won't continue until the ConnectionPoolMutex is released from MoveConnectionBackToPool std::unique_lock lockForPoolCleaning( CurlConnectionPool::g_curlConnectionPool.ConnectionPoolMutex); - Log::Write(Logger::Level::Verbose, "Clean pool sleep"); + // Wait for the default time OR to the signal from the conditional variable. // wait_for releases the mutex lock when it goes to sleep and it takes the lock again when it // wakes up (or it's cancelled). @@ -207,9 +210,6 @@ static void CleanupThread() })) { // Cancelled by another thead or no connections on wakeup - Log::Write( - Logger::Level::Verbose, - "Clean pool - no connections on wake - return *************************"); CurlConnectionPool::g_curlConnectionPool.IsCleanThreadRunning = false; break; } @@ -217,7 +217,6 @@ static void CleanupThread() decltype(CurlConnectionPool::g_curlConnectionPool .ConnectionPoolIndex)::mapped_type connectionsToBeCleaned; - Log::Write(Logger::Level::Verbose, "Clean pool - inspect pool"); // loop the connection pool index - Note: lock is re-taken for the mutex // Notes: The size of each host-index is always expected to be greater than 0 because the // host-index is removed anytime it becomes empty. @@ -249,7 +248,6 @@ static void CleanupThread() if (connectionList.empty()) { - Log::Write(Logger::Level::Verbose, "Clean pool - remove index " + index->first); index = CurlConnectionPool::g_curlConnectionPool.ConnectionPoolIndex.erase(index); } else