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

Data race in CalcGmtOffset according to Thread Sanitizer #1148

Open
aidangoettsch opened this issue Jan 26, 2025 · 1 comment
Open

Data race in CalcGmtOffset according to Thread Sanitizer #1148

aidangoettsch opened this issue Jan 26, 2025 · 1 comment

Comments

@aidangoettsch
Copy link

I'm working on a program which has several threads that log. When running under thread sanitizer, we see races related to google::LogMessageTime::CalcGmtOffset(), frequently with this malloc/free pattern. It seems like glog is intended to behave well under thread sanitizer and my understanding is that locking outside glog is not necessary. I would appreciate any advice to understand why this is happening. We can suppress this location, but it would be nice to have a better understanding of what is going on here.

WARNING: ThreadSanitizer: data race (pid=700438)
  Write of size 8 at 0x7204000002b0 by thread T18:
    #0 free <null> (binary_name+0x9c8d4) (BuildId: 2b3461021462dd0c9b963684d29b6a32fc66bc4b)
    #1 tzset_internal /usr/src/debug/glibc/glibc/time/tzset.c:401:3 (libc.so.6+0xd5ff5) (BuildId: 98b3d8e0b8c534c769cb871c438b4f8f3a8e4bf3)
    #2 google::LogMessageTime::CalcGmtOffset() <null> (binary_name+0x2dada8) (BuildId: 2b3461021462dd0c9b963684d29b6a32fc66bc4b)
    #3 google::LogMessageTime::init(tm const&, long, double) <null> (binary_name+0x2dac60) (BuildId: 2b3461021462dd0c9b963684d29b6a32fc66bc4b)
    #4 google::LogMessageTime::LogMessageTime(long, double) <null> (binary_name+0x2dad07) (BuildId: 2b3461021462dd0c9b963684d29b6a32fc66bc4b)
    #5 google::LogMessage::Init(char const*, int, int, void (google::LogMessage::*)()) <null> (binary_name+0x2d5cc0) (BuildId: 2b3461021462dd0c9b963684d29b6a32fc66bc4b)
    #6 google::LogMessage::LogMessage(char const*, int) <null> (binary_name+0x2d6c7b) (BuildId: 2b3461021462dd0c9b963684d29b6a32fc66bc4b)
...user code, std::thread launch routines

  Previous write of size 8 at 0x7204000002b0 by main thread:
    #0 malloc <null> (binary_name+0x9bebc) (BuildId: 2b3461021462dd0c9b963684d29b6a32fc66bc4b)
    #1 strdup /usr/src/debug/glibc/glibc/string/strdup.c:42:15 (libc.so.6+0xabcdf) (BuildId: 98b3d8e0b8c534c769cb871c438b4f8f3a8e4bf3)
    #2 google::LogMessageTime::CalcGmtOffset() <null> (binary_name+0x2dada8) (BuildId: 2b3461021462dd0c9b963684d29b6a32fc66bc4b)
    #3 google::LogMessageTime::init(tm const&, long, double) <null> (binary_name+0x2dac60) (BuildId: 2b3461021462dd0c9b963684d29b6a32fc66bc4b)
    #4 google::LogMessageTime::LogMessageTime(long, double) <null> (binary_name+0x2dad07) (BuildId: 2b3461021462dd0c9b963684d29b6a32fc66bc4b)
    #5 google::LogMessage::Init(char const*, int, int, void (google::LogMessage::*)()) <null> (binary_name+0x2d5cc0) (BuildId: 2b3461021462dd0c9b963684d29b6a32fc66bc4b)
    #6 google::LogMessage::LogMessage(char const*, int) <null> (binary_name+0x2d6c7b) (BuildId: 2b3461021462dd0c9b963684d29b6a32fc66bc4b)
...user code

  Thread T18 (tid=700465, running) created by main thread at:
    #0 pthread_create <null> (binary_name+0x9d759) (BuildId: 2b3461021462dd0c9b963684d29b6a32fc66bc4b)
    #1 __gthread_create /usr/src/debug/gcc/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu/bits/gthr-default.h:676:35 (libstdc++.so.6+0xe1d31) (BuildId: 4c06d605b755e81d6c346bb8a1be8bc85f13f81f)
    #2 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State>>, void (*)()) /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/thread.cc:172:37 (libstdc++.so.6+0xe1d31)
...user code
@sergiud
Copy link
Collaborator

sergiud commented Jan 26, 2025

You are using an old and unsupported version of glog. In 0.7.x google::LogMessageTime::CalcGmtOffset no longer exists.

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

2 participants