Opened 15 years ago

Closed 14 years ago

#1900 closed bug (fixed)

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

Reported by: lutra Owned by: rugginoso
Priority: critical: causes crash or data corruption Milestone: Version 1.5.0
Component: GRASS Version: Trunk
Keywords: Cc: pcav, rblazek
Must Fix for Release: Yes Platform: All
Platform Version: Awaiting user input: no

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.

Attachments (1)

Screenshot.jpg (242.1 KB ) - added by lutra 15 years ago.

Download all attachments as: .zip

Change History (13)

by lutra, 15 years ago

Attachment: Screenshot.jpg added

comment:1 by jef, 15 years ago

not reproducable here using the spearfish dataset.

in reply to:  1 ; comment:2 by lutra, 15 years ago

Replying to 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.

in reply to:  2 comment:3 by jef, 15 years ago

Replying to lutra:

Replying to 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.

comment:4 by lutra, 15 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&)


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

in reply to:  4 ; comment:5 by jef, 15 years ago

Replying to lutra:

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

fixed - patch replaced.

in reply to:  5 comment:6 by lutra, 15 years ago

Replying to 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.

comment:7 by lutra, 15 years ago

Type: bugpatch

Applies the same patch of #1878

comment:8 by jef, 15 years ago

Resolution: fixed
Status: newclosed

fixed in r11560

comment:9 by lutra, 15 years ago

Milestone: Version 1.3.0Version 1.4.0
Platform: WindowsUnix
Resolution: fixed
Status: closedreopened
Summary: windows: qgis crashes after closing a GRASS mapsetQgis crashes after closing a GRASS mapset
Type: patchbug

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

comment:10 by pcav, 14 years ago

Component: Data ProviderGRASS

comment:11 by lutra, 14 years ago

Cc: rugginoso removed
Must Fix for Release: NoYes
Owner: changed from nobody to rugginoso
Platform: UnixAll
Status: reopenednew
Summary: Qgis crashes after closing a GRASS mapsetQgis crashes after closing a GRASS mapset and removing a GRASS layer from the legend

comment:12 by rblazek, 14 years ago

Cc: rblazek added
Resolution: fixed
Status: newclosed

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

Note: See TracTickets for help on using tickets.