This forum has been archived. All content is frozen. Please use KDE Discuss instead.

race condition in manage_caching_sizes

Tags: None
(comma "," separated)
ptucker
Registered Member
Posts
1
Karma
0
version 3 GeneralBlockingPanelKernel.h contains lazy initialization of static int vars in manage_caching_sizes(). The init test is a check of m_l1CacheSize == 0. It's possible for the first thread in to set this value, but fail to set m_l2CacheSize before a second thread picks up the uninitialized value. When the uninitialized values are erroneously read, it can lead to infinite loops because it causes blocking sizes to get set to 0, which can then used for loop counter increments.

I believe the proper solution is either mutex protection or eager initialization during program startup time, neither of which seems to fit into the current design of the library. However, the code as it stands could be improved by using (m_l2CacheSize == 0) as the gating check instead.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
In the meantime you can workaround by calling:

std::ptrdiff_t k, m, n;
Eigen::computeProductBlockingSizes<double,double>(k, m, n);

at the start of your program.

Instead of mutex I guess we could directly use atomic test and set operations.
andrew207
Registered Member
Posts
1
Karma
0
OS
I am really glad that I found your site.. Thanks so much for the helpful information.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]