This is C++ on Linux. I'm getting the error during runtime, and I've narrowed down the code to be here, which is a constructor of a custom object. What I do is create a new thread and pass a function to it. In this function, I call the constructor like this:
ColorNinja cn(gameData->difficulty);
gameData is a struct that's also passed to the thread, where difficulty is an int member variable.
I don't fully understand the error or exactly what's causing it. Does anyone have any insight?
Here is the constructor. I can provide more code if necessary.
ColorNinja::ColorNinja(int difficulty) {
// create the engine that will generate random numbers
random_device rand;
mt19937 engine(rand());
int randomNumber = 0;
// possible colors that can be present on the randomly-generated game board
vector<string> possibleColors = {"red", "blue", "yellow", "green"};
uniform_int_distribution<int> distribution2(0, possibleColors.size());
// build the game board by choosing and inserting random colors
for (int i = 0; i < 4; i++) {
randomNumber = distribution2(engine);
gameBoard.push_back(possibleColors[randomNumber]);
}
// print the game board
cout << "gameBoard.size(): " << gameBoard.size() << endl;
for (string s : gameBoard) {
cout << s << endl;
}
}