Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] r.sim.water: buffer overflow #4810

Open
neteler opened this issue Dec 7, 2024 Discussed in #4709 · 0 comments
Open

[Bug] r.sim.water: buffer overflow #4810

neteler opened this issue Dec 7, 2024 Discussed in #4709 · 0 comments
Labels
bug Something isn't working raster Related to raster data processing
Milestone

Comments

@neteler
Copy link
Member

neteler commented Dec 7, 2024

Moved here from discussion in #4709

Error Report (grass84): While working on enhancing the r.sim.water documentation, I encountered a buffer overflow during testing. Below are the details:

Python commands:

Step 1: Generate dx and dy derivatives using r.slope.aspect

#Calculate the slope derivatives from the elevation map
dx = 'dx_slope'
dy = 'dy_slope'

#Run the r.slope.aspect command to get x and y slopes
gs.run_command('r.slope.aspect',
               elevation=dem,
               dx=dx,
               dy=dy,
               overwrite=True)

Step 2: Run r.sim.water with the required parameters, including dx and dy

#Now that we have the dx and dy maps, we can proceed with `r.sim.water`
gs.run_command('r.sim.water',
               elevation=dem,
               dx=dx,
               dy=dy,
               rain_value=rain_intensity,
               depth=output_depth,
               discharge=output_discharge,
               overwrite=True)

Step 3: Run r.sim.sediment (optional, if you wish to model sediment as well)

soil_texture = 'soils_texture'  # Example soil texture map, if available
output_erosion = 'erosion'
output_deposition = 'deposition'

gs.run_command('r.sim.sediment',
               elevation=dem,
               water_depth=output_depth,
               sediment_detachment=output_erosion,
               sediment_deposition=output_deposition,
               overwrite=True)

print("Simulation completed successfully!")

Error Message:

Number of threads: 1
default nwalk=120040200, rwalk=120040200.000000

Min elevation = 55.89 m
Max elevation = 156.33 m
Mean Source Rate (rainf. excess or sediment) = 0.000000 m/s or kg/m2s
Mean flow velocity = 0.081579 m/s
Mean Mannings = 2.972316
Number of iterations = 4 cells_
Time step = 30.64 s
*** buffer overflow detected ***: terminated
---------------------------------------------------------------------------
CalledModuleError                         Traceback (most recent call last)
<ipython-input-30-d891834eab96> in <cell line: 16>()
     14 # Now that we have the dx and dy maps, we can proceed with r.sim.water
     15 
---> 16 gs.run_command('r.sim.water',
     17                elevation=dem,
     18                dx=dx,

1 frames
/usr/lib/grass84/etc/python/grass/script/core.py in handle_errors(returncode, result, args, kwargs)
    364     else:
    365         module, code = get_module_and_code(args, kwargs)
--> 366         raise CalledModuleError(module=module, code=code, returncode=returncode)
    367 
    368 

CalledModuleError: Module run `r.sim.water --o elevation=elevation dx=dx_slope dy=dy_slope rain_value=50 depth=water_depth discharge=water_discharge` ended with an error.
The subprocess ended with a non-zero return code: -6. See errors above the traceback or in the error output.

Steps Taken:

  1. Verified input maps (elevation, dx_slope, dy_slope).
  2. Adjusted parameters such as nwalkers and niterations.
  3. Ensured computational region matches the elevation map.
  4. Despite these attempts, the error persists.

Could this issue be due to specific input data characteristics or a module-level limitation?

Request:

  • Suggestions for debugging the buffer overflow.
  • Insights on parameters or configurations to test further.
  • If applicable, guidance on reporting this as a bug.
@neteler neteler added bug Something isn't working raster Related to raster data processing labels Dec 7, 2024
@neteler neteler added this to the 8.5.0 milestone Dec 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working raster Related to raster data processing
Projects
None yet
Development

No branches or pull requests

1 participant