-
Notifications
You must be signed in to change notification settings - Fork 177
Description
Describe the bug
r.accumulate extension consistently fails with an integer overflow in memory allocation, attempting to allocate approximately 18 exabytes regardless of input data size.
To reproduce
- Prepare a D8 direction raster (values 1-8) and a cost/weight raster
- Run r.accumulate with direction and weight parameters:
gs.run_command("r.accumulate", direction="direction_raster", weight="cost_raster", accumulation="output")
Error occurs during "Allocating buffers..." phase
ERROR: G_realloc: unable to allocate 18446744047939747840 bytes of memory
at /tmp/grass8-.../r.accumulate/grass_addons/src/raster/r.accumulate/accumulate_iterative.c:271
Expected behavior
r.accumulate should process cost-weighted flow accumulation with reasonable memory usage proportional to input data size (not in exabytes).
Screenshot
System description
Operating System: Linux Rocky 9
GRASS GIS version: 8.4.1
Additional context
Always requests exactly 18,446,744,047,939,747,840 bytes
Resolution independent: Same error occurs with 6.6M cells (30m resolution) and 202k cells (120m resolution)
Format independent: Fails with both auto-detected and explicit format="45deg"
Data independent: Occurs with valid D8 direction codes (1-8) and positive cost values
Input data characteristics:
Direction raster: Valid D8 format, integer type, ~34% null cells
Weight raster: Positive cost values ranging 291-181,228, no obvious corruption
Both rasters: Proper extents and data types
The consistent error size regardless of input suggests an integer overflow in buffer size calculation within the iterative accumulation algorithm.