在对我的程序进行Hel差制分析时,我注意到我收到了许多类似于以下的错误:
==8347== Possible data race during read of size 4 at 0x53C47A0 by thread #2
==8347== Locks held: none
==8347== at 0x50E4E68: std::locale::locale() (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
==8347== by 0x515B1DE: std::__cxx11::basic_stringstream<
我有一个多线程程序,在这个程序中,一些线程会导致异常。我在gdb中运行了它,在异常发生和程序终止后,它会给出以下输出:
terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)
Thread 46 "MyProgram" received signal SIGABRT, Aborted.
[Switching to
我使用的是一个外部库,我既不能控制它,也不知道它的内部结构(让我们称它为专有回调)。
我知道我有一个名为callbacks的类,它有两个布尔变量:
class callbacks : public proprietarycallbacks {
bool a = false;
bool b = false;
virtual callbackHandler() {
cout "callback received\n";
b = true;
}
}
然后我有另一个类,它继承自回调类:
class MyObject : public callbacks
如果我用kthread_run创建一个内核线程,然后立即执行kthread_stop,那么内核线程可能会在不运行的情况下停止运行。我在Linux5.4.73中检查了kthread_run和kthread_stop的源代码
/**
* kthread_run - create and wake a thread.
* @threadfn: the function to run until signal_pending(current).
* @data: data ptr for @threadfn.
* @namefmt: printf-style name for the thre