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

GRASS crashes when try to create mapset #28148

Closed
qgib opened this issue Nov 2, 2018 · 21 comments
Closed

GRASS crashes when try to create mapset #28148

qgib opened this issue Nov 2, 2018 · 21 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Crash/Data Corruption GRASS High Priority Regression Something which used to work, but doesn't anymore

Comments

@qgib
Copy link
Contributor

qgib commented Nov 2, 2018

Author Name: Vitor Silva (Vitor Silva)
Original Redmine Issue: 20327
Affected QGIS version: 3.4.0
Redmine category:grass


Hi,

I can´t create a mapset in QGIS, always crash at this moment.
The report is this:

Crash ID: f3b94088ad28fd40600a5d0e06b9c43ac6243e50

Stack Trace

RtlRaiseStatus :
memset :
setjmpex :
G_fatal_error :
G_getenv :
read_datum_table :
GPJ_osr_to_grass :
GPJ_wkt_to_grass :
version :
version :
QMetaObject::activate :
QWizard::subTitleFormat :
QWizard::next :
QMetaObject::activate :
QAbstractButton::clicked :
QAbstractButton::click :
QAbstractButton::mouseReleaseEvent :
QWidget::event :
QApplicationPrivate::notify_helper :
QApplication::notify :
QgsApplication::notify :
QCoreApplication::notifyInternal2 :
QApplicationPrivate::sendMouseEvent :
QSizePolicy::QSizePolicy :
QSizePolicy::QSizePolicy :
QApplicationPrivate::notify_helper :
QApplication::notify :
QgsApplication::notify :
QCoreApplication::notifyInternal2 :
QGuiApplicationPrivate::processMouseEvent :
QWindowSystemInterface::sendWindowSystemEvents :
QEventDispatcherWin32::processEvents :
CallWindowProcW :
DispatchMessageW :
QEventDispatcherWin32::processEvents :
qt_plugin_query_metadata :
QEventLoop::exec :
QCoreApplication::exec :
main :
BaseThreadInitThunk :
RtlUserThreadStart :

QGIS Info
QGIS Version: 3.4.0-Madeira
QGIS code revision: 4a4b62e
Compiled against Qt: 5.11.2
Running against Qt: 5.11.2
Compiled against GDAL: 2.3.2
Running against GDAL: 2.3.2

System Info
CPU Type: x86_64
Kernel Type: winnt
Kernel Version: 10.0.17134


Related issue(s): #26961 (duplicates), #27352 (duplicates), #27502 (duplicates), #28030 (duplicates)
Redmine related issue(s): 19131, 19525, 19677, 20209


@qgib
Copy link
Contributor Author

qgib commented Nov 2, 2018

Author Name: Giovanni Manghi (@gioman)


Confirmed regression on Windows (on Linux seems ok).


  • regression was changed from 0 to 1
  • operating_system was changed from windows 10 to windows
  • crashes_corrupts_data was changed from 0 to 1

@qgib
Copy link
Contributor Author

qgib commented Nov 11, 2018

Author Name: Jürgen Fischer (@jef-n)


@qgib
Copy link
Contributor Author

qgib commented Nov 11, 2018

Author Name: Jürgen Fischer (@jef-n)


@qgib
Copy link
Contributor Author

qgib commented Nov 11, 2018

Author Name: Jürgen Fischer (@jef-n)


@qgib
Copy link
Contributor Author

qgib commented Nov 11, 2018

Author Name: Jürgen Fischer (@jef-n)


@izavicentini
Copy link

Same happening here

User Feedback

trying to open a new grass mapset

Report Details

Crash ID: 04af5a3de1425f04e55cf380ad5cfd9474dff246

Stack Trace

memset :
RecordShutdownReason :
_C_specific_handler :
_chkstk :
RtlUnwindEx :
_C_specific_handler :
_chkstk :
RtlRaiseException :
RtlRaiseStatus :
RtlUnwindEx :
longjmp :
G_fatal_error :
G_getenv :
read_datum_table :
GPJ_osr_to_grass :
GPJ_wkt_to_grass :
version :
version :
QMetaObject::activate :
QWizard::subTitleFormat :
QWizard::next :
QMetaObject::activate :
QAbstractButton::clicked :
QAbstractButton::click :
QAbstractButton::mouseReleaseEvent :
QWidget::event :
QApplicationPrivate::notify_helper :
QApplication::notify :
QgsApplication::notify :
QCoreApplication::notifyInternal2 :
QApplicationPrivate::sendMouseEvent :
QSizePolicy::QSizePolicy :
QSizePolicy::QSizePolicy :
QApplicationPrivate::notify_helper :
QApplication::notify :
QgsApplication::notify :
QCoreApplication::notifyInternal2 :
QGuiApplicationPrivate::processMouseEvent :
QWindowSystemInterface::sendWindowSystemEvents :
QEventDispatcherWin32::processEvents :
DispatchMessageW :
NotifyWinEvent :
QEventDispatcherWin32::processEvents :
qt_plugin_query_metadata :
QEventLoop::exec :
QCoreApplication::exec :
main :
BaseThreadInitThunk :
RtlUserThreadStart :

QGIS Info
QGIS Version: 3.8.1-Zanzibar
QGIS code revision: dcd95cc
Compiled against Qt: 5.11.2
Running against Qt: 5.11.2
Compiled against GDAL: 2.4.1
Running against GDAL: 2.4.1

System Info
CPU Type: x86_64
Kernel Type: winnt
Kernel Version: 6.3.9600

@blazek
Copy link
Member

blazek commented Sep 19, 2019

It is hard for me to debug/develop on Windows, unfortunately I cannot easily build master even on my Debian 9 with Qt 5.7 as Qt 5.9 is required. I can guess from traceback and give some suggestions.

Calls chain seems to be (I don't know why it is not in traceback):

QgsGrassNewMapset::setProjectionPage()
QgsGrassNewMapset::setGrassProjection()
GPJ_wkt_to_grass()
GPJ_osr_to_grass()
read_datum_table()
G_gisbase()
G_getenv("GISBASE")
G_fatal_error(_("Variable '%s' not set"), name)

so it looks like a banal missing GISBASE environment variable. Anyway, it should not crash if GISBASE is not set, this should catch the exception in qgsgrassnewmapset.cpp and show a warning instead

G_TRY
{
    int ret = GPJ_wkt_to_grass( &mCellHead, &mProjInfo, &mProjUnits, wkt, 0 );
}
G_CATCH( QgsGrass::Exception & e )
{
    QgsGrass::warning( tr( "Cannot create new location: %1" ).arg( e.what() ) );
    return;
}

Then remains the problem with GISBASE, I see that GISBASE set in ms-windows/osgeo4w/package.cmd

for %%g IN (%GRASS_VERSIONS%) do (
  set path=!path!;%OSGEO4W_ROOT%\apps\grass\%%g\lib
  set GISBASE=%OSGEO4W_ROOT%\apps\grass\%%g
)

Could it be that OSGeo4W network installer works but standalone package does not set up GISBASE correctly when installed in a non standard dir?

@jef-n
Copy link
Member

jef-n commented Sep 19, 2019

Then remains the problem with GISBASE, I see that GISBASE set in ms-windows/osgeo4w/package.cmd

The GISBASE in package.cmd is just there for the unit tests.

Could it be that OSGeo4W network installer works but standalone package does not set up GISBASE correctly when installed in a non standard dir?

There shouldn't be a significant difference between the standalone and the OSGeo4W. The standalone is built from OSGeo4W packages.

If you use the QGIS shortcut without GRASS the grassplugin will not load - only if you use "QGIS X with GRASS Y" it will be available. BTW I can create mapsets and open mapsets (ie. the one from the qgis sample data) w/o a crash. But I can't seem to find the GRASS browser - should be somewhere, should it?

@blazek
Copy link
Member

blazek commented Sep 19, 2019

The GISBASE in package.cmd is just there for the unit tests.

So where / how is the GISBASE set when QGIS is started? The plugin will load if libs are in path, but it needs GISBASE path set to where GRASS is installed to really work.

But I can't seem to find the GRASS browser

It was integrated into standard QGIS browser, GRASS location/mapset directories should be recognized and appear in the browser with GRASS icons and special options.

@jef-n
Copy link
Member

jef-n commented Sep 19, 2019

It was integrated into standard QGIS browser, GRASS location/mapset directories should be recognized and appear in the browser with GRASS icons and special options.

ah, so that works for me too.

@jef-n
Copy link
Member

jef-n commented Sep 19, 2019

So where / how is the GISBASE set when QGIS is started? The plugin will load if libs are in path, but it needs GISBASE path set to where GRASS is installed to really work.

The qgis starter batch file runs call "%OSGEO4W_ROOT%\apps\grass\grass76\etc\env.bat, which in turn has set GISBASE=%OSGEO4W_ROOT%\apps\grass\grass76 (and that's also copied into the .env corresponding to the qgis*.exe - for later invocations of the .exe w/o the batch file - eg. when pinned).

@blazek
Copy link
Member

blazek commented Sep 19, 2019

The qgis starter batch file runs call "%OSGEO4W_ROOT%\apps\grass\grass76\etc\env.batonly with "QGIS X with GRASS Y" shortcut?

I don't remember osgeo4w, GRASS libs are in GRASS lib dir or in a common lib dir? Might it happen that GRASS libs are in PATH and plugin loads even if grass76\etc\env.bat was not called?

We need feedback from somebody who can reproduce the crash. Please try to run in Python console in QGIS

import os
os.environ['GISBASE']

@DelazJ
Copy link
Contributor

DelazJ commented Sep 19, 2019

when run using qgis-dev-g7.bat or qgis-dev-bin-g7.exe file (from osgeo4w advanced install), I get

>>>import os 
>>>os.environ['GISBASE']
'C:/OSGEO4~1/apps/grass/grass76'

Running the simple qgis-dev.bat, I get

>>>import os
>>>os.environ['GISBASE']
Traceback (most recent call last):
 File "C:\OSGEO4~1\apps\Python37\lib\code.py", line 90, in runcode
   exec(code, self.locals)
 File "<input>", line 1, in <module>
 File "C:\OSGEO4~1\apps\Python37\lib\os.py", line 678, in __getitem__
   raise KeyError(key) from None
KeyError: 'GISBASE'

PS: Overlooked that Radim was referring to someone reproducing the crash, so you can scratch my comment

blazek added a commit to blazek/QGIS that referenced this issue Sep 19, 2019
@blazek
Copy link
Member

blazek commented Sep 19, 2019

Fix to catch the crash is here blazek@8707affbd, not tested.

@gioman gioman changed the title Grass crashes when try to create mapset GRASS crashes when try to create mapset Feb 19, 2020
@gioman
Copy link
Contributor

gioman commented Feb 20, 2020

Fix to catch the crash is here blazek@8707aff, not tested.

@blazek Hi Radim, is there any chance to revive this patch as a pull request?

@blazek
Copy link
Member

blazek commented Feb 24, 2020

I have no chance to test it on Windows. I hesitate to create pull request for untested code. Nobody confirmed it works.

@gioman
Copy link
Contributor

gioman commented Feb 24, 2020

I have no chance to test it on Windows.

@blazek me too, I'm not able to compile on Windows. On the other hand on Linux (where I can compile) does not crash, so I have no way to test if the patch works.

@blazek
Copy link
Member

blazek commented Feb 24, 2020

It is pure C code without ifdef for win, so it should work the same on Linux and Win. I have created a new pull request: #34624

@gioman
Copy link
Contributor

gioman commented Feb 24, 2020

@blazek thanks!

@gioman
Copy link
Contributor

gioman commented Feb 27, 2020

@blazek the patch seems to work, no more crashes when creating a location/mapset on Windows!

I get a "Cannot set projection: Variable 'GISBASE' not set" along the process, not sure is related to the patch or not.

@blazek
Copy link
Member

blazek commented Mar 3, 2020

I get a "Cannot set projection: Variable 'GISBASE' not set" along the process, not sure is related to the patch or not.

Yes it is, it is the message given by the try/catch block.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Crash/Data Corruption GRASS High Priority Regression Something which used to work, but doesn't anymore
Projects
None yet
Development

No branches or pull requests

6 participants