Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSAN: LogUtil::GetLogPrefix data race #171

Open
mapleFU opened this issue Dec 11, 2024 · 1 comment
Open

TSAN: LogUtil::GetLogPrefix data race #171

mapleFU opened this issue Dec 11, 2024 · 1 comment

Comments

@mapleFU
Copy link

mapleFU commented Dec 11, 2024

The code in [1] calls std::localtime, which might not thread safe [2]. Sample as

WARNING: ThreadSanitizer: data race (pid=119895)
  Write of size 8 at 0x7b04000007d0 by thread T50:
    #0 free /home/admin/llvm/llvm-project-17.0.3.src/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:722:3 (cz_fs_unittest+0x28fba05)
    #1 tzset_internal /home/lyukefan/deps/glibc-2.18/time/tzset.c:440:3 (libc.so.6+0xab3da)
    #2 qcloud_cos::LogUtil::GetLogPrefix(int) <null> (cz_fs_unittest+0x3526295)

  Previous write of size 8 at 0x7b04000007d0 by thread T65:
    #0 malloc /home/admin/llvm/llvm-project-17.0.3.src/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:663:5 (cz_fs_unittest+0x28fb2ac)
    #1 __strdup /home/lyukefan/deps/glibc-2.18/string/strdup.c:42:15 (libc.so.6+0x84a7a)
    #2 qcloud_cos::LogUtil::GetLogPrefix(int)

[1] https://github.com/tencentyun/cos-cpp-sdk-v5/blob/549a3affecc0d851a8947b9684c2a09e458aadf8/src/util/log_util.cpp#L20C47-L20C62
[2] https://github.com/tencentyun/cos-cpp-sdk-v5/blob/549a3affecc0d851a8947b9684c2a09e458aadf8/src/util/log_util.cpp#L20C47-L20C62

@mapleFU
Copy link
Author

mapleFU commented Dec 11, 2024

@Huberyxiao would you mind take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant