-
-
Notifications
You must be signed in to change notification settings - Fork 363
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
The r3.gwflow
module crashes with a segmentation fault when the sink
parameter is not provided, despite being marked as optional in the documentation and parser.
To reproduce
-
Start GRASS and set a 3D region:
g.region res=10 res3=10 n=100 s=0 e=100 w=0 t=50 b=0
-
Create minimal input maps:
r3.mapcalc expression="phead = 50" --o r3.mapcalc expression="status = 1" --o r3.mapcalc expression="hydcond = 0.0001" --o r3.mapcalc expression="syield = 0.001" --o
-
Run
r3.gwflow
without providing thesink
parameter:r3.gwflow phead=phead status=status hc_x=hydcond hc_y=hydcond \ hc_z=hydcond yield=syield output=result velocity_x=vx \ velocity_y=vy velocity_z=vz budget=budget
-
Observe the segmentation fault.
Expected behavior
If sink
is not provided, the module should:
- Either gracefully fall back to using a zero-valued sink field internally,
- Or document
sink
as a required parameter and fail with a clear error message if omitted.
Screenshots

System description
- Operating System: Windows Subsystem for Linux (WSL)
- GRASS GIS version: 8.4
- details about further software components
- GRASS 8.5.0dev
- Python verison: 3.10.12
- wxPython version: 4.2.2
Possible Root Cause
The issue appears to come from the unconditional access of param.q->answer
in the C source (main.c
), even when sink
is not set by the user. This leads to dereferencing a NULL pointer and crashing the module.
I would be happy to submit a patch for this, either to:
- Add null-checks and initialize a zero-valued map internally if unset, or
- Update the parser and docs to mark
sink
as required.
Looking forward to making the preferred change.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working