Modify

Opened 18 months ago

Closed 18 months ago

Last modified 18 months ago

#23309 closed defect (fixed)

NPE: Cannot invoke "org.openstreetmap.josm.tools.GeoPropertyIndex$GPLevel.getBounded(org.openstreetmap.josm.data.coor.LatLon)" because "this.children[idx]" is null

Reported by: flukas.robot@… Owned by: team
Priority: normal Milestone: 23.11
Component: Core Version:
Keywords: template_report Cc:

Description

What steps will reproduce the problem?

unsure if reproducible, happened once, asked to report

  1. delete only data layed
  2. add more gpx track (~4MB)
  3. select small sparsely mapped area
  4. try download data

What is the expected result?

data downloaded

What happens instead?

crash window + asked to report bug

Please provide any additional information below. Attach a screenshot if possible.

Relative:URL: ^/trunk
Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2023-08-29 13:38:40 +0200 (Tue, 29 Aug 2023)
Revision:18822
Build-Date:2023-08-30 01:30:57
URL:https://josm.openstreetmap.de/svn/trunk

Identification: JOSM/1.5 (18822 en) Windows 11 64-Bit
OS Build number: Windows 10 Enterprise 2009 (22621)
Memory Usage: 2448 MB / 4096 MB (1025 MB allocated, but free)
Java version: 17.0.4+8-LTS, Azul Systems, Inc., OpenJDK 64-Bit Server VM
Look and Feel: com.sun.java.swing.plaf.windows.WindowsLookAndFeel
Screen: \Display0 1920×1080 (scaling 1.00×1.00)
Maximum Screen Size: 1920×1080
Best cursor sizes: 16×16→32×32, 32×32→32×32
System property file.encoding: Cp1252
System property sun.jnu.encoding: Cp1252
Locale info: en_US
Numbers with default locale: 1234567890 -> 1234567890
VM arguments: [-Djava.net.useSystemProxies=true]
Dataset consistency test: No problems found

Plugins:
+ ImportImagePlugin (36176)
+ PicLayer (1.0.3)
+ RoadSigns (36126)
+ apache-commons (36176)
+ areaselector (2.6.2)
+ austriaaddresshelper (88)
+ auto_tools (81)
+ ejml (36176)
+ geotools (36176)
+ jackson (36176)
+ jaxb (36118)
+ jts (36004)
+ log4j (36176)
+ reltoolbox (36178)
+ utilsplugin2 (36178)

Last errors/warnings:
- 160303.769 W: java.net.SocketTimeoutException: Connect timed out
- 160303.769 E: java.net.SocketTimeoutException: Connect timed out
- 160303.770 W: org.openstreetmap.josm.io.OsmTransferException: Could not connect to the OSM server. Please check your internet connection.. Cause: java.net.SocketTimeoutException: Connect timed out
- 200770.582 E: Connection to proxy '/10.255.46.226:3128' for URI 'https://api.openstreetmap.org/api/0.6/user/details' failed. Exception was: java.net.SocketTimeoutException: Connect timed out
- 200785.588 W: java.net.SocketTimeoutException: Connect timed out
- 200785.589 W: Already here java.net.SocketTimeoutException: Connect timed out
- 200785.590 E: java.net.SocketTimeoutException: Connect timed out
- 200785.590 W: org.openstreetmap.josm.io.OsmTransferException: Could not connect to the OSM server. Please check your internet connection.. Cause: java.net.SocketTimeoutException: Connect timed out
- 438425.420 E: Error in primitive hover listener: java.lang.NullPointerException. Cause: java.lang.NullPointerException: Cannot invoke "org.openstreetmap.josm.tools.GeoPropertyIndex$GPLevel.getBounded(org.openstreetmap.josm.data.coor.LatLon)" because "this.children[idx]" is null
- 438425.429 E: Handled by bug report queue: java.lang.NullPointerException. Cause: java.lang.NullPointerException: Cannot invoke "org.openstreetmap.josm.tools.GeoPropertyIndex$GPLevel.getBounded(org.openstreetmap.josm.data.coor.LatLon)" because "this.children[idx]" is null



=== REPORTED CRASH DATA ===
BugReportExceptionHandler#handleException:
No data collected.

Warning issued by: BugReportExceptionHandler#handleException

=== STACK TRACE ===
Thread: AWT-EventQueue-0 (23) of main
java.lang.NullPointerException
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Unknown Source)
	at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinTask.getThrowableException(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinTask.reportException(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinTask.invoke(Unknown Source)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateParallel(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
	at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source)
	at org.openstreetmap.josm.tools.Territories.getRegionalTaginfoUrls(Territories.java:242)
	at org.openstreetmap.josm.gui.dialogs.properties.PropertiesDialog.setupTaginfoNationalActions(PropertiesDialog.java:408)
	at org.openstreetmap.josm.gui.dialogs.properties.PropertiesDialog.updateUi(PropertiesDialog.java:726)
	at org.openstreetmap.josm.gui.dialogs.properties.PropertiesDialog.updateUi(PropertiesDialog.java:705)
	at org.openstreetmap.josm.gui.dialogs.properties.PropertiesDialog.primitiveHovered(PropertiesDialog.java:691)
	at org.openstreetmap.josm.gui.NavigatableComponent.lambda$firePrimitiveHovered$2(NavigatableComponent.java:193)
	at org.openstreetmap.josm.gui.util.GuiHelper.runInEDT(GuiHelper.java:200)
	at org.openstreetmap.josm.gui.NavigatableComponent.firePrimitiveHovered(NavigatableComponent.java:190)
	at org.openstreetmap.josm.gui.NavigatableComponent.updateHoveredPrimitive(NavigatableComponent.java:204)
	at org.openstreetmap.josm.gui.NavigatableComponent.access$100(NavigatableComponent.java:80)
	at org.openstreetmap.josm.gui.NavigatableComponent$PrimitiveHoverMouseListener.mouseMoved(NavigatableComponent.java:1796)
	at java.desktop/java.awt.AWTEventMulticaster.mouseMoved(Unknown Source)
	at java.desktop/java.awt.AWTEventMulticaster.mouseMoved(Unknown Source)
	at java.desktop/java.awt.AWTEventMulticaster.mouseMoved(Unknown Source)
	at java.desktop/java.awt.Component.processMouseMotionEvent(Unknown Source)
	at java.desktop/javax.swing.JComponent.processMouseMotionEvent(Unknown Source)
	at java.desktop/java.awt.Component.processEvent(Unknown Source)
	at java.desktop/java.awt.Container.processEvent(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Unknown Source)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Unknown Source)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.NullPointerException: Cannot invoke "org.openstreetmap.josm.tools.GeoPropertyIndex$GPLevel.getBounded(org.openstreetmap.josm.data.coor.LatLon)" because "this.children[idx]" is null
	at org.openstreetmap.josm.tools.GeoPropertyIndex$GPLevel.getBounded(GeoPropertyIndex.java:142)
	at org.openstreetmap.josm.tools.GeoPropertyIndex$GPLevel.getBounded(GeoPropertyIndex.java:142)
	at org.openstreetmap.josm.tools.GeoPropertyIndex$GPLevel.getBounded(GeoPropertyIndex.java:142)
	at org.openstreetmap.josm.tools.GeoPropertyIndex$GPLevel.getBounded(GeoPropertyIndex.java:142)
	at org.openstreetmap.josm.tools.GeoPropertyIndex$GPLevel.getBounded(GeoPropertyIndex.java:142)
	at org.openstreetmap.josm.tools.GeoPropertyIndex$GPLevel.get(GeoPropertyIndex.java:81)
	at org.openstreetmap.josm.tools.GeoPropertyIndex$GPLevel.get(GeoPropertyIndex.java:83)
	at org.openstreetmap.josm.tools.GeoPropertyIndex$GPLevel.get(GeoPropertyIndex.java:83)
	at org.openstreetmap.josm.tools.GeoPropertyIndex$GPLevel.get(GeoPropertyIndex.java:83)
	at org.openstreetmap.josm.tools.GeoPropertyIndex$GPLevel.get(GeoPropertyIndex.java:83)
	at org.openstreetmap.josm.tools.GeoPropertyIndex$GPLevel.get(GeoPropertyIndex.java:83)
	at org.openstreetmap.josm.tools.GeoPropertyIndex.get(GeoPropertyIndex.java:49)
	at org.openstreetmap.josm.tools.Territories.lambda$getRegionalTaginfoUrls$4(Territories.java:237)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
	at java.base/java.util.HashMap$EntrySpliterator.forEachRemaining(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
	at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(Unknown Source)
	at java.base/java.util.stream.StreamSpliterators$DistinctSpliterator.forEachRemaining(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
	at java.base/java.util.stream.ReduceOps$ReduceTask.doLeaf(Unknown Source)
	at java.base/java.util.stream.ReduceOps$ReduceTask.doLeaf(Unknown Source)
	at java.base/java.util.stream.AbstractTask.compute(Unknown Source)
	at java.base/java.util.concurrent.CountedCompleter.exec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)

Attachments (1)

Screenshot 2023-11-19 025758.png (1.1 MB ) - added by anonymous 18 months ago.

Download all attachments as: .zip

Change History (9)

by anonymous, 18 months ago

comment:1 by anonymous, 18 months ago

but data loaded despite error shown

comment:2 by taylor.smock, 18 months ago

Summary: Bug during downloadNPE: Cannot invoke "org.openstreetmap.josm.tools.GeoPropertyIndex$GPLevel.getBounded(org.openstreetmap.josm.data.coor.LatLon)" because "this.children[idx]" is null

I don't know how this happened -- there is a null check right before the location where the exception occurred.

I wasn't able to reproduce.

comment:3 by gaben, 18 months ago

Possible duplicates #23036, #22834.

in reply to:  3 ; comment:4 by gaben, 18 months ago

Replying to gaben:

Possible duplicates #23036, #22834.

@taylor, which ticket should be the parent for the rest?

Also I see a parallel stream in getRegionalTaginfoUrls(), maybe there is a race condition? It's just a wild guess, I haven't checked deeper than that.

in reply to:  4 comment:5 by taylor.smock, 18 months ago

Replying to gaben:

@taylor, which ticket should be the parent for the rest?

I typically go in the following order:

  • Ticket with the most information (prefer oldest)
  • Oldest ticket with a non-anonymous reporter
  • Oldest ticket

This is definitely a duplicate with #23036 and probably with #22834.

Also I see a parallel stream in getRegionalTaginfoUrls(), maybe there is a race condition? It's just a wild guess, I haven't checked deeper than that.

That is a possibility

            if (children == null) {
                @SuppressWarnings("unchecked")
                GPLevel<T>[] tmp = new GPLevel[4];
                this.children = tmp; // If this happens after the null check but before the getBounded call, an npe could happen.
            }
[...]
                    if (children[idx] == null) {
                        if (DEBUG) System.err.println(" - new with idx "+idx);
                        children[idx] = new GPLevel<>(level + 1, testBBox, this, owner);
                    }
                    return children[idx].getBounded(ll);

comment:6 by taylor.smock, 18 months ago

Ticket #23036 has been marked as a duplicate of this ticket.

comment:7 by taylor.smock, 18 months ago

Resolution: fixed
Status: newclosed

In 18903/josm:

Fix #23309: NPE in GeoPropertyIndex$GPLevel.getBounded when called by Territories.getRegionalTaginfoUrls

Territories.getRegionalTaginfoUrls uses Collection.parallelStream
which could cause the following race conditions:

  • children is reinitialized after the null check, potentially causing an NPE due to a different null check becoming false after it was checked. Solution: either synchronize the creation of children or have a local variable.
  • Two threads could generate a child and then generate children of children, creating a split tree hierarchy, only one of which would be kept. Solution: synchronize the creation of the child nodes

For both of the new synchronized methods, we could use a safe double-lock
idiom if there ends up being performance issues. This probably won't be the case.
Profiling JOSM start to end with Mesa County, CO (+ validations) did not show
that the modified methods were "hot".

This additionally fixes some lint issues and converts some package-private
methods to use ILatLon instead of LatLon.

comment:8 by taylor.smock, 18 months ago

Milestone: 23.11

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.