Bug report #1900

Qgis crashes after closing a GRASS mapset and removing a GRASS layer from the legend

Added by Giovanni Manghi about 11 years ago. Updated over 10 years ago.

Status:Closed
Priority:Low
Assignee:Lorenzo Masini
Category:GRASS
Affected QGIS version: Regression?:No
Operating System:All Easy fix?:No
Pull Request or Patch supplied: Resolution:fixed
Crashes QGIS or corrupts data: Copied to github as #:11960

Description

I can see the following behaviour with some data (the qgis sample dataset for example). I'm using qgis dev version (1.3) installed via osgeo4w.

To replicate do the following:

*) open the qgis sample (GRASS) dataset

*) add a vector layer

*) close the GRASS mapset (without removing the GRASS vector layer)

*) close qgis (file -> exit)

it is first thrown a warning "variable LOCATION_NAME not set" that appears also under linux, but then under windows the program crashes. See attached image.

Not really sure to what component assign this ticket.

Screenshot.jpg (242 KB) Giovanni Manghi, 2009-08-26 11:56 AM

Associated revisions

Revision 0b697b8c
Added by Jürgen Fischer about 11 years ago

apply #1878 (fixes #1900)

git-svn-id: http://svn.osgeo.org/qgis/trunk/[email protected] c8812cc2-4d05-0410-92ff-de0c093fc19c

Revision 43408110
Added by Jürgen Fischer about 11 years ago

apply #1878 (fixes #1900)

git-svn-id: http://svn.osgeo.org/qgis/[email protected] c8812cc2-4d05-0410-92ff-de0c093fc19c

History

#1 Updated by Jürgen Fischer about 11 years ago

not reproducable here using the spearfish dataset.

#2 Updated by Giovanni Manghi about 11 years ago

Replying to [comment:1 jef]:

not reproducable here using the spearfish dataset.

Hi,

yes, it doesn't happen with all GRASS mapsets, but i found a few ones that lead qgis to this behavior. Try for example the qgis sample dataset, where you can find a GRASS mapset.

#3 Updated by Jürgen Fischer about 11 years ago

Replying to [comment:2 lutra]:

Replying to [comment:1 jef]:

not reproducable here using the spearfish dataset.

Hi,

yes, it doesn't happen with all GRASS mapsets, but i found a few ones that lead qgis to this behavior. Try for example the qgis sample dataset, where you can find a GRASS mapset.

The patch in #1878 should fix this - please test.

#4 Updated by Giovanni Manghi about 11 years ago

Hi,

if I apply the patch I get the following error while compiling.

By the way I cannot compile under windows, so it would be hard in any case to say if the crash is gone or not.

In file included from /home/gio/Desktop/qgis_unstable/src/providers/grass/qgsgrassprovider.cpp:19:
/home/gio/Desktop/qgis_unstable/src/providers/grass/qgsgrass.h: In constructor ‘QgsGrass::Exception::Exception(const char*)’:
/home/gio/Desktop/qgis_unstable/src/providers/grass/qgsgrass.h:37: error: no matching function for call to ‘std::exception::exception(const char*&)’
/usr/include/c++/4.3/exception:59: note: candidates are: std::exception::exception()
/usr/include/c++/4.3/exception:57: note:                 std::exception::exception(const std::exception&)

maker2: *** [src/providers/grass/CMakeFiles/qgisgrass.dir/qgsgrassprovider.o] Error 1
maker1: *** [src/providers/grass/CMakeFiles/qgisgrass.dir/all] Error 2
make: *** [all] Error 2

#5 Updated by Jürgen Fischer about 11 years ago

Replying to [comment:4 lutra]:

if I apply the patch I get the following error while compiling.

fixed - patch replaced.

#6 Updated by Giovanni Manghi about 11 years ago

Replying to [comment:5 jef]:

fixed - patch replaced.

Hi Jurgen,
the patch under linux works, the warning message is gone. If the warning message is the source for the crash under windows, then the problem should be fixed.

Thanks.

#7 Updated by Giovanni Manghi about 11 years ago

Applies the same patch of #1878

#8 Updated by Jürgen Fischer about 11 years ago

  • Resolution set to fixed
  • Status changed from Open to Closed

fixed in 43408110 (SVN r11561)

#9 Updated by Giovanni Manghi almost 11 years ago

  • Status changed from Closed to Feedback
  • Resolution deleted (fixed)

I have to reopen this ticket because I'm seeing this behaviour again (under Ubuntu 9.04, both qgis 1.3 from repo and 1.4 trunk).

Open a GRASS mapset, add a layer, close the mapset, remove the layer from legend -> qgis crashes

terminate called after throwing an instance of 'QgsGrass::Exception'
  what():  G_getenv(): Variable LOCATION_NAME not set
Aborted

#10 Updated by Giovanni Manghi almost 11 years ago

  • Status changed from Feedback to Open

#11 Updated by Redmine Admin over 10 years ago

  • Status changed from Open to Closed
  • Resolution set to fixed

There are 2 problems here:

1) Bug in GDAL GRASS provider (http://trac.osgeo.org/gdal/ticket/3313), if MAPSET is unset, the next attempt to read GRASS raster data results in GRASS fatal error. I have written a patch for GDAL (waiting for approval) and temporal fix for QGIS in changeset:12687.

2) Another proble is, how GRASS fatal errors are handled and that is quite interesting. It is possible to set a routine which handles GRASS errors with G_set_error_routine. The problem is, that both QGIS GRASS plugin and GDAL GRASS driver do it. GDAL sets Grass2CPLErrorHook while GRASS QgsGrass::error_routine. When an error happens in GDAL it does not call the Grass2CPLErrorHook but QgsGrass::error_routine because the routine was reset in the mean time by QGIS GRASS plugin. QgsGrass::error_routine throws QgsGrass::Exception but that is not caught by raster layer renderer (right, it is expecting error from GDAL) and thus qgis crashes. Isn't it nice!?

I don't know how to solve this at moment, but I close this bug as 1) is resolved and I create a new ticket for 2) : #2347

Also available in: Atom PDF