James, I am unable to reproduce this (on Windows using VS 2022 v.17.4.4 and on Ubuntu 22.04 (WSL) using GCC 11.3.0). I take it you are using GCC. What version? Are you linking any additional libraries to your Chrono build? Any changes to CMakeLists or to compiler flags? --Radu
From: [email protected] <[email protected]> On Behalf Of James Baxter Sent: Thursday, 23 February 2023 23:25 To: ProjectChrono <[email protected]> Subject: [chrono] Double free caused by use of HMMWV and LinkLocks I've encountered a memory error that I can't seem to figure out. It seems to be that the HMMWV_Full destructors cause the (internal to the suspension) LinkLock destructors to do a double free, only if a link lock class is referenced (but not necessarily used) in the class. Here is a minimal example: #include <chrono_models/vehicle/hmmwv/HMMWV.h> #include <chrono/physics/ChLinkLock.h> using namespace chrono; using namespace chrono::vehicle; using namespace chrono::vehicle::hmmwv; void foo() { auto bar = chrono_types::make_shared<ChLinkLockRevolute>(); } int main(int argc, char* argv[]) { HMMWV_Full my_hmmwv; my_hmmwv.SetContactMethod(ChContactMethod::SMC); my_hmmwv.SetChassisCollisionType(CollisionType::NONE); my_hmmwv.SetChassisFixed(false); my_hmmwv.SetInitPosition(CSYSNORM); my_hmmwv.SetPowertrainType(PowertrainModelType::SHAFTS); my_hmmwv.SetDriveType(DrivelineTypeWV::AWD); my_hmmwv.UseTierodBodies(true); my_hmmwv.SetSteeringType(SteeringTypeWV::PITMAN_ARM); my_hmmwv.SetBrakeType(BrakeType::SHAFTS); my_hmmwv.SetTireType(TireModelType::TMEASY); my_hmmwv.SetTireStepSize(1e-3); my_hmmwv.Initialize(); return 0; } You can see that the function `foo` isn't even called, yet it's existence causes the crash. If commented out, there are no issues. Here is the output (development branch): Chrono was not built with Thrust support. CHRONO collision system type not available. double free or corruption (out) Aborted I've attached Valgrind output too, which is more detailed. I'm hoping that there is something really simple or obvious that I'm missing here. Thanks in advance for any help figuring this out. -- You received this message because you are subscribed to the Google Groups "ProjectChrono" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]<mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/projectchrono/43a25eec-b573-493e-ae60-04dc1b2c899dn%40googlegroups.com<https://groups.google.com/d/msgid/projectchrono/43a25eec-b573-493e-ae60-04dc1b2c899dn%40googlegroups.com?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "ProjectChrono" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/projectchrono/PH0PR06MB82376C6867B9D04882EBE86DA7A99%40PH0PR06MB8237.namprd06.prod.outlook.com.
