I have a global vector of vector of structs of this form:
vector<vector<stackEntry>> shadowStacksVector
where the idea is to have a vector<stackEntry>
per thread.
In the thread start function I do the following:
vector<stackEntry> sstack;
shadowStacksVector.push_back(sstack);
tdata->shadowStack = &(shadowStacksVector.back());
where tdata
is a struct containing the thread local storage.
What I would like to do is to have, for each thread, a reference to the vector of stack entries, so that each thread can add or remove elements to its own stack.
Conceptually I believe that push_back
does a copy of the element so I thought that this should have worked. However, when I try to add/remove elements from tdata->shadowStack
my program crashes.
On the contary, if I replace the vector of vectors with an array like this:
vector<stackEntry> shadowStacksVector[256]
everything works fine.