Data races in Geometry.java
I have created a tool that detect data races in java.
The tool has detected the following races in Geometry.java:
#0 org.sunflow.core.Geometry.intersect() Geometry.java:93
#1 org.sunflow.core.Instance.intersect() Instance.java:135
#2 org.sunflow.core.InstanceList.intersectPrimitive() InstanceList.java:30
#3 org.sunflow.core.accel.BoundingIntervalHierarchy.intersect() BoundingIntervalHierarchy.java:559
#4 org.sunflow.core.Scene.trace() Scene.java:199
#5 org.sunflow.core.LightServer$1.run() LightServer.java:231
#6 java.lang.Thread.run() Thread.java:844
Previous write of size 8 at 0x7f2a7ef10038 by thread T16:
#0 org.sunflow.core.Geometry.build() Geometry.java:119
#1 org.sunflow.core.Geometry.intersect() Geometry.java:-1
#2 org.sunflow.core.Instance.intersect() Instance.java:135
#3 org.sunflow.core.InstanceList.intersectPrimitive() InstanceList.java:30
#4 org.sunflow.core.accel.BoundingIntervalHierarchy.intersect() BoundingIntervalHierarchy.java:559
#5 org.sunflow.core.Scene.trace() Scene.java:199
#6 org.sunflow.core.LightServer$1.run() LightServer.java:231
#7 java.lang.Thread.run() Thread.java:844```
Read of size 8 at 0x7f2a7ef10038 by thread T24:
#0 org.sunflow.core.Geometry.intersect() Geometry.java:93
#1 org.sunflow.core.Instance.intersect() Instance.java:135
#2 org.sunflow.core.InstanceList.intersectPrimitive() InstanceList.java:30
#3 org.sunflow.core.accel.BoundingIntervalHierarchy.intersect() BoundingIntervalHierarchy.java:559
#4 org.sunflow.core.Scene.trace() Scene.java:199
#5 org.sunflow.core.LightServer$1.run() LightServer.java:231
#6 java.lang.Thread.run() Thread.java:844
Previous write of size 8 at 0x7f2a7ef10038 by thread T16:
#0 org.sunflow.core.Geometry.build() Geometry.java:119
#1 org.sunflow.core.Geometry.intersect() Geometry.java:-1
#2 org.sunflow.core.Instance.intersect() Instance.java:135
#3 org.sunflow.core.InstanceList.intersectPrimitive() InstanceList.java:30
#4 org.sunflow.core.accel.BoundingIntervalHierarchy.intersect() BoundingIntervalHierarchy.java:559
#5 org.sunflow.core.Scene.trace() Scene.java:199
#6 org.sunflow.core.LightServer$1.run() LightServer.java:231
#7 java.lang.Thread.run() Thread.java:844
Those have been detected by running the DaCapo Benchmark Suite 23.11-Chopin.
I second this. I've been working on a Java Multi-Version Execution and Record Replay tool called JMVX ( public git, paper ) and observed races here too during testing.
Additionally I think there is a chance to race on the builtTess field.
builtAccel and builtTess act as flags in part of a double check lock. The race on those fields can be eliminated by making the fields volatile. I imagine the same is true of the accel field, if the problem doesn't go away from fixing builtAccel. My testing was also done with the DaCapo Benchmark suite (version 23.11). Based on the code in master the issue should still be present.