Last active
March 19, 2016 23:29
-
-
Save RoyBellingan/3afebad0c57b21ae5661 to your computer and use it in GitHub Desktop.
Small demo to crash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <QMap> | |
| #include <QMapIterator> | |
| #include <thread> | |
| #include <QMutex> | |
| QMap<int,QMap<QByteArray,QByteArray>> me; | |
| QMap<QByteArray,QByteArray> row; | |
| QMutex mutex; | |
| void blaxx(){ | |
| while(true){ | |
| for (int i = 0; i < 200;) { | |
| mutex.lock(); | |
| me.insert(i,row); | |
| mutex.unlock(); | |
| i=i+5; | |
| } | |
| } | |
| } | |
| int main(){ | |
| row.insert("srly","lol"); | |
| std::thread th[1]; | |
| th[0] = std::thread(blaxx); | |
| mutex.lock(); | |
| me.insert(10,row); | |
| mutex.unlock(); | |
| while(true){ | |
| int k=4; | |
| QMap<int,QMap<QByteArray,QByteArray>>::iterator iter = me.begin(); | |
| while(iter != me.end()){ | |
| k = k + 5; | |
| QString dbname = iter.value().value("blablabla"); | |
| mutex.lock(); | |
| me.insert(k,row); | |
| iter = me.erase(iter); | |
| mutex.unlock(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment