Opened 5 years ago

Last modified 4 years ago

#3833 new defect

pygrass.gis.region.Region + WIND_OVERRIDE + non-existing path kills the process

Reported by: pmav99 Owned by: grass-dev@…
Priority: normal Milestone: 7.8.3
Component: PyGRASS Version: unspecified
Keywords: Cc:
CPU: Unspecified Platform: Unspecified

Description

If you define WIND_OVERRIDE to a non existing path, then, instantiating a Region object results in a fatal error which kills the current process. This is a problem if you are e.g. in an interactive ipython session. Example:

import os
from grass.pygrass.gis.region import Region

os.environ["WIND_OVERRIDE"] = 'aaaa'
r = Region()

# results in a dead python process with the following message:
# ERROR: Unable to open element file <windows> for <aaaa@PERMANENT>

The problem is that the Region.read() method calls G_get_window which calls G_get_element_window, which calls G_fatal_window if the file does not exist.

Adding a check for WIND_OVERRIDE and the existence of the file in Region.read() would solve the issue for most practical purposes, but would be subject to a race condition. Not sure what to suggest.

Change History (2)

comment:1 by pmav99, 5 years ago

OK, the problem seems to be that the generated gis.py (i.e. lib/python/ctypes/OBJ.x86_64-pc-linux-gnu/gis.py]), doesn't define errcheck for some of the functions, including G_get_window and G_get_element_window. Can anyone provide a hint, why these functions don't have errcheck defined while others do?

Some relevant links:

Last edited 5 years ago by pmav99 (previous) (diff)

comment:2 by neteler, 4 years ago

Milestone: 7.8.3
Note: See TracTickets for help on using tickets.