You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, according to documentation here, vector's erase() function should be used to remove an item from the vector and subsequently destroy it. We've run into problems where the vector still tracked a previously freed item and then tried to free it again, causing a segfault.
Also, this applies to all modules (I just included the above as an example case), and we implemented our fix like this: this->eclipseOutMsgs.erase(this->eclipseOutMsgs.begin()+c);
The text was updated successfully, but these errors were encountered:
erase destroys the element so shouldn't be automatically calling delete on raw pointers. That would only work if the elements were unique_ptr or something, otherwise the erase operation should leak memory.
Hi sassy-asjp,
Thanks for the reply. I've researched this more and it looks like if you have to use raw pointers you should delete them, and THEN call erase so the vector doesn't count them as part of its list anymore. Is there any reason, though, why you're not using smart pointers?
basilisk/src/simulation/environment/eclipse/eclipse.cpp
Line 35 in ddd3571
Hi, according to documentation here, vector's erase() function should be used to remove an item from the vector and subsequently destroy it. We've run into problems where the vector still tracked a previously freed item and then tried to free it again, causing a segfault.
Also, this applies to all modules (I just included the above as an example case), and we implemented our fix like this:
this->eclipseOutMsgs.erase(this->eclipseOutMsgs.begin()+c);
The text was updated successfully, but these errors were encountered: