I'm gonna guess you're storing an iterator somewhere and the push_back invalidates the iterator.
I'm also puzzled at the parameter type for createEntity. A simple pointer would make more sense, although it wouldn't be the cause of your problem.
I use VS C++.
Also an infinite loop wouldn't throw an error.