godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.48k stars 21.26k forks source link

Reading from a 2 dimensional array in multiple threads results in values that are not in the array #98171

Open D0V4HKIIN opened 1 month ago

D0V4HKIIN commented 1 month ago

Tested versions

System information

Godot v4.3.stable (77dcf97d8) - Gentoo 2.15 - Wayland - Vulkan (Forward+) - integrated AMD Radeon Graphics (RADV RENOIR) - AMD Ryzen 5 5600U with Radeon Graphics (12 Threads)

Issue description

When reading a 2 dimensional array with multiple threads, some values read are not values that are in the original array.

Steps to reproduce

  1. Create 2 dimensional of at least size 2 (i.e. [[], []])
  2. Create multiple threads
  3. Print values in 2d array
  4. Notice values being printed that are not in the original array.

Minimal reproduction project (MRP)

MRP.zip

AThousandShips commented 1 month ago

You are looping forever, and it won't print anything in my testing, when fixing the code by removing the infinite loop, then it just prints nothing as intended

When looping a single time or a fixed number of times nothing is printed and everything works as expected

D0V4HKIIN commented 1 month ago

Hmm I am not getting this behavior at all. I will come back with a screen recording when I have time.

AThousandShips commented 1 month ago

Haven't tested in 4.3 but the MRP you provided doesn't do what you are describing, did you actually test with the MRP?

D0V4HKIIN commented 1 month ago

Here is the output that I am getting. Also the output changes from time to time (guess depending on what is in memory).

https://github.com/user-attachments/assets/17e17848-c66b-4e0f-8ad6-be5ae39cbf03

AThousandShips commented 1 month ago

Please show your errors, and please try without the infinite loop

D0V4HKIIN commented 1 month ago

Ran the MRP again

Output image

Errors: 388 times the same error (and once it complaining about icon.svg missing) image

Debugger: image

D0V4HKIIN commented 1 month ago

Without the infinite loop it doesn't complain and doesn't print anything.

The goal of the infinite loop is to trigger what I believe is some race condition.