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

ThreadSanitizer: std::localtime() is not thread-safe. #4303

Closed
JinheLin opened this issue Mar 16, 2022 · 0 comments · Fixed by #4344
Closed

ThreadSanitizer: std::localtime() is not thread-safe. #4303

JinheLin opened this issue Mar 16, 2022 · 0 comments · Fixed by #4344
Assignees
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. severity/minor type/bug The issue is confirmed as a bug.

Comments

@JinheLin
Copy link
Contributor

JinheLin commented Mar 16, 2022

Bug Report

ThreadSanitizer reports that DB::UnifiedLogPatternFormatter::getTimestamp() has data race.

SUMMARY: ThreadSanitizer: data race /home/jenkins/agent/workspace/tiflash-sanitizer-daily/tiflash/dbms/src/Common/UnifiedLogPatternFormatter.cpp:109:26 in DB::UnifiedLogPatternFormatter::getTimestamp()

Following the code, std::localtime() which called by DB::UnifiedLogPatternFormatter::getTimestamp() is not thread-safe and I think this is the problem.

I think we should use localtime_r() to replace std::localtime().

@JinheLin JinheLin added the type/bug The issue is confirmed as a bug. label Mar 16, 2022
@JaySon-Huang JaySon-Huang added help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. severity/minor labels Mar 16, 2022
@Lloyd-Pottiger Lloyd-Pottiger self-assigned this Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. severity/minor type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants