Skip to content

Commit dbdabc1

Browse files
committed
mutex fix
1 parent 96cdd56 commit dbdabc1

7 files changed

Lines changed: 344 additions & 194 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## 26.1.1
22
- Updated CMake minimum required version to use the range format with upper the end of `3.31`.
3+
- Hardened mutex handling against exceptions.
34

45
## 26.1.0
56
- ! Minor breaking change ! SDK Behavior Settings is now enabled by default. Changes made on SDK Manager > SDK Behavior Settings on your server will affect SDK behavior directly.

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ if(COUNTLY_BUILD_TESTS)
119119
${CMAKE_CURRENT_SOURCE_DIR}/tests/request.cpp
120120
${CMAKE_CURRENT_SOURCE_DIR}/tests/config.cpp
121121
${CMAKE_CURRENT_SOURCE_DIR}/tests/immediate_stop.cpp
122+
${CMAKE_CURRENT_SOURCE_DIR}/tests/mutex_exception_safety.cpp
122123
${CMAKE_CURRENT_SOURCE_DIR}/tests/sbs.cpp)
123124

124125
target_compile_options(countly-tests PRIVATE -g)

include/countly.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,14 @@ class Countly : public cly::CountlyDelegates {
313313
*/
314314
std::vector<std::string> debugReturnStateOfEQ();
315315

316+
/**
317+
* Injects a raw (possibly malformed) string directly into the in-memory event
318+
* queue, bypassing serialization. Used only by the mutex exception-safety test
319+
* to force a parse failure inside the locked section of updateSession().
320+
* Warning: This method is for debugging purposes, and it is going to be removed in the future.
321+
*/
322+
void debugInjectRawEvent(const std::string &raw);
323+
316324
/**
317325
* This function should not be used as it will be removed in a future release.
318326
* It is currently added as a temporary workaround.
@@ -331,6 +339,8 @@ class Countly : public cly::CountlyDelegates {
331339

332340
inline void clearRequestQueue() {
333341
if (is_sdk_initialized) {
342+
// serialize storage access with the background processQueue thread
343+
std::lock_guard<std::mutex> lk(*mutex);
334344
requestModule->clearRequestQueue();
335345
}
336346
}

0 commit comments

Comments
 (0)