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)

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

Reply via email to