First of all always show code examples that can be compiled without errors.
The code your showed is irrelevant relative to the error you got.
In this non-compiled example
while( <1000000) {
vector<int> stackVector;
stackVector.push_back(1);
vectorOfmyTypes.pushback(make_pair(1,stackVector);
}
the lifetime of local object stackVector
has nothing common with the lfetime of the element of vector vectorOfmyTypes
that is added to the vector by using the push_back..
I only can guess that it seems that you placed in the vector a pointer to a local vector. In this case indeed the lifetime of the local vector influenced on the validation of the pointer.
For example
std::vector<std::pair<int, std::vector<int> *>> vectorOfmyTypes;
size_t i = 0;
while ( i < 1000000 )
{
std::vector<int> stackVector;
stackVector.push_back( i++ );
vectorOfmyTypes.push_back( std::make_pair( 1, &stackVector );
}