-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Copious TSAN warnings on Linux #14710
Comments
Example output:
|
V1 review: fixes in master for this are bug fixes and would be acceptable, however this is not a V1 blocker. |
This might be related: https://gitlab.gnome.org/GNOME/glib/-/issues/1672 |
I've done some tests of this issue and it seems that on Ubuntu 22.04 TSAN has been fixed - it no longer reports such false positives. One can use provided simple test code to check that with different TSAN versions. Compile the test code as follows: test.cpp#include <iostream>
#include <thread>
#include <glib.h>
struct data {
int value;
};
static struct data *sharedData1;
static struct data *sharedData2;
void glibMainLoopThread(GMainLoop *loop) {
g_main_loop_run(loop);
}
gboolean glibCallback1(void * data) {
auto *sharedData = reinterpret_cast<struct data *>(data);
std::cout << "T: sharedData1 = " << sharedData->value << std::endl;
sharedData->value++;
return FALSE;
}
gboolean glibCallback2(void * data) {
auto *sharedData = reinterpret_cast<struct data *>(data);
std::cout << "T: sharedData2 = " << sharedData->value << std::endl;
sharedData->value++;
return FALSE;
}
int main() {
sharedData1 = new struct data({10});
GMainLoop *loop = g_main_loop_new(NULL, FALSE);
std::thread t(glibMainLoopThread, loop);
sharedData2 = new struct data({20});
// That's not a data race
// NOTE: TSAN on Ubuntu 20.04 reports it (false positive)
std::cout << "sharedData1 = " << sharedData1->value << std::endl;
std::cout << "sharedData2 = " << sharedData2->value << std::endl;
g_idle_add(glibCallback1, sharedData1);
g_idle_add(glibCallback2, sharedData2);
// Here we've got a data race (callback is already added to main loop thread)
// std::cout << "sharedData2 = " << sharedData2->value << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(1));
g_main_loop_quit(loop);
t.join();
std::cout << "sharedData1 = " << sharedData1->value << std::endl;
std::cout << "sharedData2 = " << sharedData2->value << std::endl;
delete sharedData1;
delete sharedData2;
return 0;
} On Ubuntu 22.04 I've got no errors (unless commented Output from Ubuntu 22.04:
With our CI the problem occurs because as for now the |
Issue Scrub: @woody-apple to pin us to ubuntu-22.04 in CI. @andy31415 will help check to make sure warnings aren't being suppressed afterwards. |
After more research I've found the TRUE cause of false positives. The proper answer is here: https://stackoverflow.com/a/74328089 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Problem
We have lots and lots of TSAN data race warnings on Linux that should be addressed before it results in other potentially bigger blow-ups that are more difficult to debug later.
Example: https://github.com/project-chip/connectedhomeip/runs/5039936950?check_suite_focus=true
The text was updated successfully, but these errors were encountered: