Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayIndexOutOfBoundsException during core graph preparation for hgv #1181

Closed
aoles opened this issue Jun 3, 2022 · 1 comment · Fixed by #1183
Closed

ArrayIndexOutOfBoundsException during core graph preparation for hgv #1181

aoles opened this issue Jun 3, 2022 · 1 comment · Fixed by #1183
Assignees
Labels
bug 🐞 Erroneous behavior of the backend

Comments

@aoles
Copy link
Member

aoles commented Jun 3, 2022

As reported on the ask forum, build of bengaluru.pbf against app.config.txt fails with the following error.

The underlying problem might be the same as for a similar issue reported earlier, which unfortunately we couldn't reproduce.

03 Jun 17:13:41 WARN [extensions.ORSOSMReader] - Index 1048576 out of bounds for length 1048576. Way id = 363083979
03 Jun 17:14:06 ERROR [routing.RoutingProfileManager] - java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException: Index 1048576 out of bounds for length 1048576
03 Jun 17:14:06 ERROR [routing.RoutingProfileManager] - Failed to initialize RoutingProfileManager instance.
java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException: Index 1048576 out of bounds for length 1048576
	at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:?]
	at java.util.concurrent.FutureTask.get(FutureTask.java:191) ~[?:?]
	at org.heigit.ors.routing.RoutingProfileManager.initialize(RoutingProfileManager.java:178) ~[classes/:?]
	at org.heigit.ors.routing.RoutingProfileManager.getInstance(RoutingProfileManager.java:72) ~[classes/:?]
	at org.heigit.ors.routing.RoutingProfileManager.isInitComplete(RoutingProfileManager.java:668) ~[classes/:?]
	at org.heigit.ors.servlet.listeners.ORSKafkaConsumerInitContextListener.lambda$contextInitialized$0(ORSKafkaConsumerInitContextListener.java:47) ~[classes/:?]
	at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException: Index 1048576 out of bounds for length 1048576
	at org.heigit.ors.routing.graphhopper.extensions.core.CoreAlgoFactoryDecorator.prepare(CoreAlgoFactoryDecorator.java:314) ~[classes/:?]
	at org.heigit.ors.routing.graphhopper.extensions.ORSGraphHopper.prepareCore(ORSGraphHopper.java:787) ~[classes/:?]
	at org.heigit.ors.routing.graphhopper.extensions.ORSGraphHopper.postProcessing(ORSGraphHopper.java:690) ~[classes/:?]
	at com.graphhopper.GraphHopper.process(GraphHopper.java:703) ~[graphhopper-core-v0.13.21.jar:?]
	at com.graphhopper.GraphHopper.importOrLoad(GraphHopper.java:680) ~[graphhopper-core-v0.13.21.jar:?]
	at org.heigit.ors.routing.graphhopper.extensions.ORSGraphHopper.importOrLoad(ORSGraphHopper.java:169) ~[classes/:?]
	at org.heigit.ors.routing.RoutingProfile.initGraphHopper(RoutingProfile.java:182) ~[classes/:?]
	at org.heigit.ors.routing.RoutingProfile.<init>(RoutingProfile.java:126) ~[classes/:?]
	at org.heigit.ors.routing.RoutingProfileLoader.call(RoutingProfileLoader.java:35) ~[classes/:?]
	at org.heigit.ors.routing.RoutingProfileLoader.call(RoutingProfileLoader.java:21) ~[classes/:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[?:?]
	... 1 more
Caused by: java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException: Index 1048576 out of bounds for length 1048576
	at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:?]
	at java.util.concurrent.FutureTask.get(FutureTask.java:191) ~[?:?]
	at org.heigit.ors.routing.graphhopper.extensions.core.CoreAlgoFactoryDecorator.prepare(CoreAlgoFactoryDecorator.java:310) ~[classes/:?]
	at org.heigit.ors.routing.graphhopper.extensions.ORSGraphHopper.prepareCore(ORSGraphHopper.java:787) ~[classes/:?]
	at org.heigit.ors.routing.graphhopper.extensions.ORSGraphHopper.postProcessing(ORSGraphHopper.java:690) ~[classes/:?]
	at com.graphhopper.GraphHopper.process(GraphHopper.java:703) ~[graphhopper-core-v0.13.21.jar:?]
	at com.graphhopper.GraphHopper.importOrLoad(GraphHopper.java:680) ~[graphhopper-core-v0.13.21.jar:?]
	at org.heigit.ors.routing.graphhopper.extensions.ORSGraphHopper.importOrLoad(ORSGraphHopper.java:169) ~[classes/:?]
	at org.heigit.ors.routing.RoutingProfile.initGraphHopper(RoutingProfile.java:182) ~[classes/:?]
	at org.heigit.ors.routing.RoutingProfile.<init>(RoutingProfile.java:126) ~[classes/:?]
	at org.heigit.ors.routing.RoutingProfileLoader.call(RoutingProfileLoader.java:35) ~[classes/:?]
	at org.heigit.ors.routing.RoutingProfileLoader.call(RoutingProfileLoader.java:21) ~[classes/:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[?:?]
	... 1 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 1048576 out of bounds for length 1048576
	at com.graphhopper.util.BitUtilLittle.toShort(BitUtilLittle.java:32) ~[graphhopper-core-v0.13.21.jar:?]
	at com.graphhopper.storage.RAMDataAccess.getShort(RAMDataAccess.java:225) ~[graphhopper-core-v0.13.21.jar:?]
	at org.heigit.ors.routing.graphhopper.extensions.storages.HeavyVehicleAttributesGraphStorage.hasEdgeRestriction(HeavyVehicleAttributesGraphStorage.java:163) ~[classes/:?]
	at org.heigit.ors.routing.graphhopper.extensions.edgefilters.core.HeavyVehicleCoreEdgeFilter.accept(HeavyVehicleCoreEdgeFilter.java:33) ~[classes/:?]
	at org.heigit.ors.routing.graphhopper.extensions.edgefilters.EdgeFilterSequence.accept(EdgeFilterSequence.java:29) ~[classes/:?]
	at org.heigit.ors.routing.graphhopper.extensions.core.PrepareCore.prepareNodes(PrepareCore.java:190) ~[classes/:?]
	at org.heigit.ors.routing.graphhopper.extensions.core.PrepareCore.doSpecificWork(PrepareCore.java:175) ~[classes/:?]
	at com.graphhopper.routing.util.AbstractAlgoPreparation.doWork(AbstractAlgoPreparation.java:30) ~[graphhopper-core-v0.13.21.jar:?]
	at org.heigit.ors.routing.graphhopper.extensions.core.CoreAlgoFactoryDecorator.lambda$prepare$0(CoreAlgoFactoryDecorator.java:300) ~[classes/:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[?:?]
	... 1 more
@aoles aoles added bug 🐞 Erroneous behavior of the backend investigate 🔍 core-alt :atom: labels Jun 3, 2022
@aoles aoles self-assigned this Jun 3, 2022
@aoles aoles changed the title ArrayIndexOutOfBoundsException thrown during core graph preparation for hgv profile ArrayIndexOutOfBoundsException during core graph preparation for hgv Jun 4, 2022
@aoles
Copy link
Member Author

aoles commented Jun 7, 2022

The issue is actually not related to the core routing algorithm as the error message might indicate. The problem originates from accessing multi-byte values in RAMDataAccess objects. These objects store data in byte arrays split into segments of certain size. It turns out that the convenience methods for reading/writing multi-byte values such as get-/setShort fail at the segment boundary when the data is not properly aligned. This is the case for HeavyVehicleAttributesGraphStorage whose entries per edge take up 11 bytes: 1 byte encoding the vehicle type, and 5 shorts each consisting of two bytes for vehicle dimensions.

The error pops up already when parsing the OSM file, however, the exception is caught and converted into a warning:

WARN [extensions.ORSOSMReader] - Index 1048576 out of bounds for length 1048576. Way id = 363083979

Therefore, it is only when the storage is accessed again for the value which previously failed to store when the build errors.

As a workaround one can substitute calls to get-/setShort by calls to get-/setBytes which support multi-byte entries spread across segment boundaries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Erroneous behavior of the backend
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant