[GRASS-user] parallel grass operations
glynn at gclements.plus.com
Mon Sep 26 17:10:09 EDT 2011
Dmitriy Tyugaev wrote:
> When I run my script with parallel grass operations (about 12 processes at
> the same time), sometimes I get this error from the g.region module:
> *** glibc detected *** g.region: double free or corruption (out):
> 0x0000000015dcfdd0 ***
> ======= Backtrace: =========
> ======= Memory map: ========
> 00400000-00409000 r-xp 00000000 08:11 916425443
> 00608000-0060d000 rw-p 00008000 08:11 916425443
> 15dca000-15deb000 rw-p 15dca000 00:00 0 [heap]
> 303ee00000-303ee51000 r-xp 00000000 08:11 915563294
> Tell me please what's the problem?
The error being reported by glibc is due to the code which reads a
region from a file (e.g. the WIND file) being unable to cope with the
file changing while it's being read. First it scans the file to
determine how many lines it contains, then it reads those lines into
memory. If the file grows between the line-counting and the reading,
it ends up using more memory than it has allocated.
Normally, this shouldn't happen.
The real problem is that you're trying to run multiple GRASS commands
concurrently in the same mapset. In general, that won't work.
GRASS doesn't perform any locking on the files within a GRASS
database, so you may end up with one process reading a file while
another process is in the middle of writing it. The most problematic
case is the WIND file, which contains the current region, although
there are others.
If you want to run multiple commands concurrently, you need to take
steps to ensure that this type of conflict doesn't happen. For the
current region, you can use the WIND_OVERRIDE environment variable to
specify a named region which should be used instead of the WIND file.
Or you can use the GRASS_REGION environment variable to specify the
region parameters (the syntax is the same as the WIND file, but with
newlines replaced with semicolons). With this approach, the region can
only be read, not modified.
Problems can also arise if you read files from another mapset while
another session is modifying those files. The WIND file isn't an issue
here, nor are the files containing raster data (which are updated
atomically), but the various support files may be.
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-user