OSGeo / grass

GRASS GIS - free and open-source geospatial processing engine
https://grass.osgeo.org
Other
824 stars 301 forks source link

[Bug] Attribute table tool crashes GUI if vector does not have an attribute table #1390

Open cmbarton opened 3 years ago

cmbarton commented 3 years ago

Describe the bug If a vector map does not have an attribute table, clicking on the table tool will crash the GUI

To Reproduce Create a vector map without an attribute table (e.g., v.random) Add the random points map to the layer manager Click on the table tool An error box pops up with the message that there is no linked attribute table Click OK and the GUI crashes

Expected behavior Close the error message box without a crash Even better open v.db.addtable to create a linked attribute table

System description (please complete the following information):

cmbarton commented 3 years ago

Haven't tested but almost certainly the same behavior in ver. < 7.9

tmszi commented 2 years ago

I can't reproduce this bug with actual GRASS GIS version 7.8.6 and 8.0 dev (OS GNU/Linux Gentoo distribution, Python 3.9.7, wxPython 4.0.7.post2 gtk3 (phoenix)).

Is this bug still actual for you?

version 7.8.6

GRASS 7.8.6 (nc_spm_08_grass7):~ > g.version -rge
version=7.8.6
date=2021
revision=exported
build_date=2021-11-13
build_platform=x86_64-pc-linux-gnu
build_off_t_size=8
libgis_revision=2021-11-13T17:37:52+00:00
libgis_date=2021-11-13T09:00:00+01:00
proj=7.2.1
gdal=3.2.2
geos=3.9.1
sqlite=3.35.5

import sys, wx; print(sys.version, wx.version())
3.9.7 (default, Nov  5 2021, 06:04:09) 
[GCC 10.3.0] 4.0.7.post2 gtk3 (phoenix) wxWidgets 3.0.5

version 8.0 dev

GRASS nc_basic_spm_grass7/PERMANENT:~ > g.version -rge
version=8.0.dev
date=2021
revision=b163eba93
build_date=2021-11-13
build_platform=x86_64-pc-linux-gnu
build_off_t_size=8
libgis_revision=d41d07412
libgis_date=2021-10-02T16:09:01+00:00
proj=7.2.1
gdal=3.2.2
geos=3.9.1
sqlite=3.35.5

import sys, wx; print(sys.version, wx.version())
3.9.7 (default, Nov  5 2021, 06:04:09) 
[GCC 10.3.0] 4.0.7.post2 gtk3 (phoenix) wxWidgets 3.0.5
cmbarton commented 1 year ago

Just tested in 8.3. Still a problem. Here is how to recreate.

Create a vector map without an attribute table. Example, using the "streams_derived" raster from the South Carolina demo data set.

r.to.vect -t --overwrite input=streams_derived@PERMANENT output=streams_from_raster type=line

Select the new vector map and try to open the attribute table manager in the GUI. A message appears saying that the vector has no attribute table. Click OK

The GUI crashes and generates this error in the terminal

Fatal Python error: PyGILState_Release: thread state 0x10126a9e8 must be current when releasing> in <nc_spm_08_grass7>
Python runtime state: initialized

Thread 0x00000002b5953000 (most recent call first):
  File "/Applications/GRASS-8.3.app/Contents/Resources/lib/python3.11/threading.py", line 320 in wait
  File "/Applications/GRASS-8.3.app/Contents/Resources/lib/python3.11/queue.py", line 171 in get
  File "/Applications/GRASS-8.3.app/Contents/Resources/gui/wxpython/core/gthread.py", line 93 in run
  File "/Applications/GRASS-8.3.app/Contents/Resources/gui/wxpython/core/gthread.py", line 154 in __run
  File "/Applications/GRASS-8.3.app/Contents/Resources/lib/python3.11/threading.py", line 1038 in _bootstrap_inner
  File "/Applications/GRASS-8.3.app/Contents/Resources/lib/python3.11/threading.py", line 995 in _bootstrap

Thread 0x00000002b2013000 (most recent call first):
  File "/Applications/GRASS-8.3.app/Contents/Resources/lib/python3.11/threading.py", line 320 in wait
  File "/Applications/GRASS-8.3.app/Contents/Resources/lib/python3.11/queue.py", line 171 in get
  File "/Applications/GRASS-8.3.app/Contents/Resources/gui/wxpython/gui_core/forms.py", line 454 in run
  File "/Applications/GRASS-8.3.app/Contents/Resources/lib/python3.11/threading.py", line 1038 in _bootstrap_inner
  File "/Applications/GRASS-8.3.app/Contents/Resources/lib/python3.11/threading.py", line 995 in _bootstrap

Thread 0x00000002b1007000 (most recent call first):
  File "/Applications/GRASS-8.3.app/Contents/Resources/lib/python3.11/threading.py", line 320 in wait
  File "/Applications/GRASS-8.3.app/Contents/Resources/lib/python3.11/queue.py", line 171 in get
  File "/Applications/GRASS-8.3.app/Contents/Resources/gui/wxpython/core/gconsole.py", line 125 in run
  File "/Applications/GRASS-8.3.app/Contents/Resources/lib/python3.11/threading.py", line 1038 in _bootstrap_inner
  File "/Applications/GRASS-8.3.app/Contents/Resources/lib/python3.11/threading.py", line 995 in _bootstrap

Thread 0x0000000177beb000 (most recent call first):
  File "/Applications/GRASS-8.3.app/Contents/Resources/lib/python3.11/threading.py", line 320 in wait
  File "/Applications/GRASS-8.3.app/Contents/Resources/lib/python3.11/queue.py", line 171 in get
  File "/Applications/GRASS-8.3.app/Contents/Resources/gui/wxpython/core/gthread.py", line 93 in run
  File "/Applications/GRASS-8.3.app/Contents/Resources/gui/wxpython/core/gthread.py", line 154 in __run
  File "/Applications/GRASS-8.3.app/Contents/Resources/lib/python3.11/threading.py", line 1038 in _bootstrap_inner
  File "/Applications/GRASS-8.3.app/Contents/Resources/lib/python3.11/threading.py", line 995 in _bootstrap

Thread 0x0000000176bdf000 (most recent call first):
  File "/Applications/GRASS-8.3.app/Contents/Resources/lib/python3.11/threading.py", line 320 in wait
  File "/Applications/GRASS-8.3.app/Contents/Resources/lib/python3.11/queue.py", line 171 in get
  File "/Applications/GRASS-8.3.app/Contents/Resources/gui/wxpython/core/gconsole.py", line 125 in run
  File "/Applications/GRASS-8.3.app/Contents/Resources/lib/python3.11/threading.py", line 1038 in _bootstrap_inner
  File "/Applications/GRASS-8.3.app/Contents/Resources/lib/python3.11/threading.py", line 995 in _bootstrap

Thread 0x0000000175bd3000 (most recent call first):
  File "/Applications/GRASS-8.3.app/Contents/Resources/lib/python3.11/threading.py", line 320 in wait
  File "/Applications/GRASS-8.3.app/Contents/Resources/lib/python3.11/queue.py", line 171 in get
  File "/Applications/GRASS-8.3.app/Contents/Resources/gui/wxpython/core/gthread.py", line 93 in run
  File "/Applications/GRASS-8.3.app/Contents/Resources/gui/wxpython/core/gthread.py", line 154 in __run
  File "/Applications/GRASS-8.3.app/Contents/Resources/lib/python3.11/threading.py", line 1038 in _bootstrap_inner
  File "/Applications/GRASS-8.3.app/Contents/Resources/lib/python3.11/threading.py", line 995 in _bootstrap

Current thread 0x00000001e9951e00 (most recent call first):
  File "/Applications/GRASS-8.3.app/Contents/Resources/gui/wxpython/dbmgr/base.py", line 3352 in _createDeletePage
  File "/Applications/GRASS-8.3.app/Contents/Resources/gui/wxpython/dbmgr/base.py", line 3112 in __init__
  File "/Applications/GRASS-8.3.app/Contents/Resources/gui/wxpython/dbmgr/base.py", line 2868 in __init__
  File "/Applications/GRASS-8.3.app/Contents/Resources/gui/wxpython/dbmgr/base.py", line 842 in CreateDbMgrPage
  File "/Applications/GRASS-8.3.app/Contents/Resources/gui/wxpython/dbmgr/manager.py", line 141 in __init__
  File "/Applications/GRASS-8.3.app/Contents/Resources/gui/wxpython/main_window/frame.py", line 1950 in OnShowAttributeTable
  File "/Applications/GRASS-8.3.app/Contents/Resources/lib/python3.11/site-packages/wx/core.py", line 2262 in MainLoop
  File "/Applications/GRASS-8.3.app/Contents/Resources/gui/wxpython/wxgui.py", line 175 in main
  File "/Applications/GRASS-8.3.app/Contents/Resources/gui/wxpython/wxgui.py", line 179 in <module>

Extension modules: wx._core, wx._adv, wx._html, osgeo._gdal, osgeo._gdalconst, osgeo._ogr, osgeo._osr, wx._stc, wx._aui, wx._glcanvas, numpy.core._multiarray_umath, numpy.core._multiarray_tests, numpy.linalg._umath_linalg, numpy.fft._pocketfft_internal, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator, PIL._imaging (total: 24)
tmszi commented 1 year ago

I can't reproduce it with Python 3.10.12 (main, Jun 24 2023, 06:37:24) [GCC 12.2.1 20230428] and wxPython 4.2.0 gtk3 (phoenix) wxWidgets 3.2.2.1 version (distribution Gentoo GNU/Linux).

marisn commented 1 year ago

I also could not reproduce this on Linux. There is a similar looking cry for help on the SO. Also on a Mac. I doubt there is anything we can do to fix this issue. https://stackoverflow.com/questions/75721987/fatal-python-error-pygilstate-release-when-writing-to-a-textctrl-from-a-radiobo

nilason commented 1 year ago

I can confirm this crash with 8.3.0 on Mac:

$GRASS_PYTHON -c "import sys, wx; print(sys.version); print(wx.version())"
Python 3.11.4 (main, Jun 10 2023, 09:07:43) [Clang 13.1.6 (clang-1316.0.21.2.5)]
wxPython 4.2.1 osx-cocoa (phoenix) wxWidgets 3.2.2.1

Seems wxPython/wxWidgets related, but perhaps avoidable with the right code from our side...

mac_crash_log.txt

petrasovaa commented 1 year ago

None of the outputs are very helpful. Is this a new behavior, maybe you could find the change that caused it. Or is it related to new version of wxPython perhaps?

nilason commented 1 year ago

None of the outputs are very helpful.

Unfortunately !

Is this a new behavior, maybe you could find the change that caused it. Or is it related to new version of wxPython perhaps?

Same result with test using bit older settings, with 7.8.6 and

$GRASS_PYTHON -c "import sys, wx; print(sys.version); print(wx.version())"
3.9.6 | packaged by conda-forge | (default, Jul 11 2021, 03:36:15) 
[Clang 11.1.0 ]
4.1.1 osx-cocoa (phoenix) wxWidgets 3.1.5
cmbarton commented 6 months ago

This still crashes the GUI in 8.4 dev