Skip to content

Commit f3f2c02

Browse files
committed
log : try to fix thread sanitizer CI
ggml-ci
1 parent 32eabcb commit f3f2c02

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

common/log.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,17 @@ struct gpt_log * gpt_log_init() {
296296
}
297297

298298
struct gpt_log * gpt_log_main() {
299-
static struct gpt_log * log = gpt_log_init();
299+
// this is supposed to be thread-safe but sanitizer complains
300+
// https://github.com/ggerganov/llama.cpp/actions/runs/10815973423/job/30006101803?pr=9418#step:6:3731
301+
//static struct gpt_log * log = gpt_log_init();
302+
303+
// let's try this instead
304+
static struct gpt_log * log = nullptr;
305+
static std::once_flag flag;
306+
std::call_once(flag, []() {
307+
log = gpt_log_init();
308+
});
309+
300310
return log;
301311
}
302312

tests/test-log.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ int main() {
99

1010
std::thread threads[n_thread];
1111
for (int i = 0; i < n_thread; i++) {
12-
threads[i] = std::thread([i]() {
12+
threads[i] = std::thread([i, n_msg]() {
1313
for (int j = 0; j < n_msg; j++) {
1414
const int log_type = std::rand() % 4;
1515

0 commit comments

Comments
 (0)