BTW, I'm using libsumo from sumo 1.15.0. -- Harmon ________________________________ From: sumo-user <[email protected]> on behalf of Nine, Harmon S via sumo-user <[email protected]> Sent: Wednesday, December 28, 2022 9:36 PM To: Nine, Harmon S via sumo-user <[email protected]> Cc: Nine, Harmon S <[email protected]> Subject: [sumo-user] "corrupted size vs. prev_size" error when using libsumo in Java
Hello. I'm using the Java interface for libsumo. When using the Vehicle.getNextTLS(vehicleId) I'm getting a "corrupted size vs prev_size" error during runtime. >From the web, it appears this occurs when "memory chunk control structure >fields in the adjacent following chunk are being overwritten due to >out-of-bounds access by the code" >(https://stackoverflow.com/questions/49628615/understanding-corrupted-size-vs-prev-size-glibc-error<https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F49628615%2Funderstanding-corrupted-size-vs-prev-size-glibc-error&data=05%7C01%7Charmon.s.nine%40vanderbilt.edu%7Ca6b9ead800b64a5a61f808dae94de365%7Cba5a7f39e3be4ab3b45067fa80faecad%7C0%7C0%7C638078818013280112%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=rIFUunEIOXixydiDeBF%2B5yQIMsDsEipSNxGwgXo6mM0%3D&reserved=0>) The code that's incurring the error is below. It appears the error happens during garbage collection, I'm guessing when the memory used by the data returned by "Vehicle.getNextTLS(vehicleId)" is reclaimed. The error occurs on the explicit call to "System.gc()". Without this call, the error occurs later, when garbage collection is implicitly called by the JVM. How can this be fixed? double oldModulus = 0; int modulusPeriod = 90; double currentTime = 0; while(true) { StringVector stringVector = Vehicle.getIDList(); for (String vehicleId : stringVector) { TraCINextTLSVector traCINextTLSVector = Vehicle.getNextTLS(vehicleId); if (traCINextTLSVector.size() > 0) { TraCINextTLSData traCINextTLSData = traCINextTLSVector.get(0); String tlsId = traCINextTLSData.getId(); if (tlsId.equals("traffic-light-id")) { if (Vehicle.getSpeed(vehicleId) == 0.0) { ++stoppedVehicles; } } } } double newModulus = currentTime - (int)(currentTime / modulusPeriod) * modulusPeriod; if (newModulus < oldModulus) { double average = stoppedVehicles/modulusPeriod; System.out.println(average); stoppedVehicles = 0; System.gc(); // WITH THIS CALL, THE "corrupted size vs. prev_size" ERROR OCCURS. } oldModulus = newModulus; currentTime += 1; } -- Harmon
_______________________________________________ sumo-user mailing list [email protected] To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/sumo-user
