Why is this giving segmenation fault?

#include
vector mainStack , temp;

MinStack::MinStack() {
mainStack.clear();
temp.clear();
}

void MinStack::push(int x) {
mainStack.push_back(x);
if( x <= temp.back() || temp.empty() ){
temp.push_back(x);
}
return;
}

void MinStack::pop() {
if( !mainStack.empty()){
if( mainStack.back() == temp.back()){
temp.pop_back();
}
mainStack.pop_back();
}
return ;
}

int MinStack::top() {
if( !mainStack.empty())return mainStack.back();
return -1 ;
}

int MinStack::getMin() {
if( !temp.empty() )return temp.back();
return -1;
}

Click here to start solving coding interview questions