PixelGuys / Cubyz

Voxel sandbox game with a large render distance, procedurally generated content and some cool graphical effects.
GNU General Public License v3.0
449 stars 55 forks source link

Potential data race in transparency sorting. #109

Closed IntegratedQuantum closed 1 year ago

IntegratedQuantum commented 1 year ago

Sadly the thread sanitizer is still broken(https://github.com/ziglang/zig/issues/15241), so I cannot get clear data on where the data race is happening. Observable symptoms:

thread 13466 panic: index out of bounds: index 78, len 62
/home/mint/Cubyz/src/chunk.zig:1095:30: 0x7deb33 in renderTransparent (Cubyzig)
     self.sortingOutputBuffer[buckets[bucket]] = self.currentSorting[i].face;
                             ^
/home/mint/Cubyz/src/renderer.zig:239:35: 0x7e6212 in renderWorld (Cubyzig)
   try meshes[i].renderTransparent(playerPos);
                                  ^
/home/mint/Cubyz/src/renderer.zig:150:18: 0x7eee0c in render (Cubyzig)
  try renderWorld(world, ambient, skyColor, playerPosition);
                 ^
/home/mint/Cubyz/src/main.zig:749:22: 0x7ffe52 in main (Cubyzig)
  try renderer.render(game.Player.getPosBlocking());
                     ^
/home/mint/Downloads/zig/lib/std/start.zig:486:37: 0x8022ee in main (Cubyzig)
    std.os.argv = @as([*][*:0]u8, @ptrCast(c_argv))[0..@as(usize, @intCast(c_argc))];
                                    ^
IntegratedQuantum commented 1 year ago

I haven't seen these in while, and I also found no data races in that code with the thread sanitizer.