grass icon indicating copy to clipboard operation
grass copied to clipboard

[Bug] r.patch fails if one input is a GRASS vrt and nprocs > 1

Open metzm opened this issue 1 month ago • 0 comments

Describe the bug

It seems there is a race condition with parallelised r.patch in G85 if one input is a GRASS vrt consisting of many files, the error is "Invalid descriptor: X" coming from https://github.com/OSGeo/grass/blob/main/lib/raster/close.c#L104. It works with nprocs=1. In a GRASS vrt, the source raster maps are opened and closed on demand in order to avoid issues like in #6615.

To reproduce

  1. Create a GRASS vrt with r.buildvrt consisting of a large number of files
  2. Use a fast CPU with at least 6 cores (not threads but real cores)
  3. Patch the GRASS vrt with another raster map using the max number of available threads

Solution

For parallelisation, some sort of file open/close lock needs to be implemented in /lib/raster

System description

G85

Additional context

Attempting to patch the results of AI models for semantic segmentation which require small input tiles of typically the size 256x256 pixels to 512x512 pixels.

metzm avatar Nov 14 '25 19:11 metzm