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

[Bug] g.gui and d.mon crash upon mouse-over due to python3.9 segfault #1123

Closed
neteler opened this issue Nov 25, 2020 · 9 comments
Closed

[Bug] g.gui and d.mon crash upon mouse-over due to python3.9 segfault #1123

neteler opened this issue Nov 25, 2020 · 9 comments
Labels
bug Something isn't working GUI wxGUI related
Milestone

Comments

@neteler
Copy link
Member

neteler commented Nov 25, 2020

Describe the bug

With the Fedora distro upgrade (F32 to F33) I now have Python 3.9.0 on my system (and wx 3.0.5).

Opening g.gui and d.mon wx0 works but as soon as I move-over the mouse the GUI/wx monitor crashes. It happens both in master and release_branch_7_8.

In the system settings I see messages like

[19025.401599] python3[142271]: segfault at 10 ip 00007f855d07d6dd sp 00007ffd0b47fc10 error 4 in libpython3.9.so.1.0[7f855cfe1000+1a9000]
[26994.092671] python3[189459]: segfault at 10 ip 00007f5ab7b3a6dd sp 00007ffce673f860 error 4 in libpython3.9.so.1.0[7f5ab7a9e000+1a9000]
[26996.799738] python3[189261]: segfault at 10 ip 00007ff0996e46dd sp 00007ffece7490e0 error 4 in libpython3.9.so.1.0[7ff099648000+1a9000]
[27017.711157] python3[189611]: segfault at 10 ip 00007fe8447e16dd sp 00007ffe1d1d5a80 error 4 in libpython3.9.so.1.0[7fe844745000+1a9000]
[27325.072026] python3[190592]: segfault at 10 ip 00007fa9ed8506dd sp 00007ffcd67bc900 error 4 in libpython3.9.so.1.0[7fa9ed7b4000+1a9000]

To Reproduce

  • use Python 3.9.0
  • recompile current master or relbranch78
  • open g.gui or d.mon wx0
  • move the mouse cursor over the window
  • the GUI crashes

System description (please complete the following information):

  • Fedora 33
g.version -rge
version=7.8.5dev
date=2020
revision=b593a718b
build_date=2020-11-23
build_platform=x86_64-pc-linux-gnu
build_off_t_size=8
libgis_revision=744fcaefa
libgis_date=2020-10-16T16:00:53+00:00
proj=6.3.2
gdal=3.1.4
geos=3.8.1
sqlite=3.33.0

python --version
Python 3.9.0

wx-config --version
3.0.5

I wonder how to debug it since it is a background process.

This doesn't show anything relevant:

g.gisenv set="DEBUG=5"
g.gisenv set="WX_DEBUG=5"

Here isn't yet too much about it...:
https://grasswiki.osgeo.org/wiki/GRASS_Debugging#wxPython_GUI_debugging

@neteler neteler added bug Something isn't working backport_needed GUI wxGUI related labels Nov 25, 2020
@neteler neteler added this to the 7.8.5 milestone Nov 25, 2020
@nilason
Copy link
Contributor

nilason commented Nov 25, 2020

This sound similar to the very difficult to solve bug trac 3487 for Mac. I went all the way to build a debug version Python, and using lldb and iPython to debug. The debugging per se didn't give much leads to the cause. Turned out the segfault was caused by incomplete generated ctypesgen files. Not implying this is the issue here, but just mentioning in case...

@petrasovaa
Copy link
Contributor

This sound similar to the very difficult to solve bug trac 3487 for Mac. I went all the way to build a debug version Python, and using lldb and iPython to debug. The debugging per se didn't give much leads to the cause. Turned out the segfault was caused by incomplete generated ctypesgen files. Not implying this is the issue here, but just mentioning in case...

Before going in that direction, try using latest wxPyhton 4.1.0 (wxWidgets 3.1). Ctypes should not be the problem here (in theory), since it's not related to any ctypes component.

@tmszi
Copy link
Member

tmszi commented Nov 25, 2020

According my testing problematic is calling PseudoDC.FindObjects() method.

System description:

>>> wx.version()
'4.0.7.post2 gtk3 (phoenix) wxWidgets 3.0.4'

python3.9 --version
Python 3.9.0

Debug info:

Thread 1 "python3.9" received signal SIGSEGV, Segmentation fault.
0x00007fbe733b26f4 in PyList_New () from /usr/lib64/libpython3.9.so.1.0
(gdb) bt
#0  0x00007efc100546f4 in PyList_New () at /usr/lib64/libpython3.9.so.1.0
#1  0x00007efc09c21173 in wxPseudoDC::FindObjects(int, int, int, wxColour const&) ()
    at /usr/lib/python3.9/site-packages/wx/_adv.cpython-39-x86_64-linux-gnu.so
#2  0x00007efc09c92dd5 in  () at /usr/lib/python3.9/site-packages/wx/_adv.cpython-39-x86_64-linux-gnu.so
#3  0x00007efc1006f6c3 in  () at /usr/lib64/libpython3.9.so.1.0
#4  0x00007efc100345bf in _PyObject_MakeTpCall () at /usr/lib64/libpython3.9.so.1.0
#5  0x00007efc0fffb06a in _PyEval_EvalFrameDefault () at /usr/lib64/libpython3.9.so.1.0
#6  0x00007efc100f9743 in  () at /usr/lib64/libpython3.9.so.1.0
#7  0x00007efc1003430a in _PyFunction_Vectorcall () at /usr/lib64/libpython3.9.so.1.0
#8  0x00007efc0fff87eb in _PyEval_EvalFrameDefault () at /usr/lib64/libpython3.9.so.1.0
#9  0x00007efc0fff19b9 in  () at /usr/lib64/libpython3.9.so.1.0
#10 0x00007efc10036f34 in  () at /usr/lib64/libpython3.9.so.1.0
#11 0x00007efc1003405e in PyVectorcall_Call () at /usr/lib64/libpython3.9.so.1.0
#12 0x00007efc0e931ae2 in wxPyCallback::EventThunker(wxEvent&) ()
    at /usr/lib/python3.9/site-packages/wx/_core.cpython-39-x86_64-linux-gnu.so
#13 0x00007efc0dd5aed1 in wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) ()
    at /usr/lib64/libwx_baseu-3.0-gtk3.so.0
#14 0x00007efc0dd5b28a in wxEvtHandler::SearchDynamicEventTable(wxEvent&) () at /usr/lib64/libwx_baseu-3.0-gtk3.so.0
#15 0x00007efc0dd5b320 in wxEvtHandler::TryHereOnly(wxEvent&) () at /usr/lib64/libwx_baseu-3.0-gtk3.so.0
#16 0x00007efc0dd5b3db in wxEvtHandler::ProcessEventLocally(wxEvent&) () at /usr/lib64/libwx_baseu-3.0-gtk3.so.0
#17 0x00007efc0dd5b481 in wxEvtHandler::ProcessEvent(wxEvent&) () at /usr/lib64/libwx_baseu-3.0-gtk3.so.0
#18 0x00007efc0ec89d1b in sipwxWindow::ProcessEvent(wxEvent&) ()
    at /usr/lib/python3.9/site-packages/wx/_core.cpython-39-x86_64-linux-gnu.so
#19 0x00007efc0dd5b207 in wxEvtHandler::SafelyProcessEvent(wxEvent&) () at /usr/lib64/libwx_baseu-3.0-gtk3.so.0
#20 0x00007efc0e113ad3 in  () at /usr/lib64/libwx_gtk3u_core-3.0-gtk3.so.0
#21 0x00007efc0d4e907b in  () at /usr/lib64/libgtk-3.so.0
#22 0x00007efc0ca46154 in g_closure_invoke () at /usr/lib64/libgobject-2.0.so.0
#23 0x00007efc0ca597a7 in  () at /usr/lib64/libgobject-2.0.so.0
#24 0x00007efc0ca64464 in g_signal_emit_valist () at /usr/lib64/libgobject-2.0.so.0
#25 0x00007efc0ca65307 in g_signal_emit () at /usr/lib64/libgobject-2.0.so.0
#26 0x00007efc0d493884 in  () at /usr/lib64/libgtk-3.so.0
#27 0x00007efc0d34cfb0 in  () at /usr/lib64/libgtk-3.so.0
#28 0x00007efc0d34f18b in gtk_main_do_event () at /usr/lib64/libgtk-3.so.0
#29 0x00007efc0d078eb5 in  () at /usr/lib64/libgdk-3.so.0
#30 0x00007efc0d0ac3d2 in  () at /usr/lib64/libgdk-3.so.0
#31 0x00007efc0c958dec in g_main_context_dispatch () at /usr/lib64/libglib-2.0.so.0
#32 0x00007efc0c959088 in  () at /usr/lib64/libglib-2.0.so.0
#33 0x00007efc0c959363 in g_main_loop_run () at /usr/lib64/libglib-2.0.so.0
#34 0x00007efc0d34e1fd in gtk_main () at /usr/lib64/libgtk-3.so.0
#35 0x00007efc0e0f2fc5 in wxGUIEventLoop::DoRun() () at /usr/lib64/libwx_gtk3u_core-3.0-gtk3.so.0
#36 0x00007efc0dc15e6d in wxEventLoopBase::Run() () at /usr/lib64/libwx_baseu-3.0-gtk3.so.0
#37 0x00007efc0dbdc486 in wxAppConsoleBase::MainLoop() () at /usr/lib64/libwx_baseu-3.0-gtk3.so.0
#38 0x00007efc0eb1cc11 in wxPyApp::MainLoop() () at /usr/lib/python3.9/site-packages/wx/_core.cpython-39-x86_64-linux-gnu.so
#39 0x00007efc0eb1ce27 in  () at /usr/lib/python3.9/site-packages/wx/_core.cpython-39-x86_64-linux-gnu.so
#40 0x00007efc1006f6a4 in  () at /usr/lib64/libpython3.9.so.1.0
#41 0x00007efc100345bf in _PyObject_MakeTpCall () at /usr/lib64/libpython3.9.so.1.0
#42 0x00007efc0fffb06a in _PyEval_EvalFrameDefault () at /usr/lib64/libpython3.9.so.1.0
#43 0x00007efc0fff19b9 in  () at /usr/lib64/libpython3.9.so.1.0
#44 0x00007efc0fff87eb in _PyEval_EvalFrameDefault () at /usr/lib64/libpython3.9.so.1.0
#45 0x00007efc100f9743 in  () at /usr/lib64/libpython3.9.so.1.0
#46 0x00007efc100f9a6e in _PyEval_EvalCodeWithName () at /usr/lib64/libpython3.9.so.1.0
#47 0x00007efc100f9abe in PyEval_EvalCodeEx () at /usr/lib64/libpython3.9.so.1.0
#48 0x00007efc100f9aeb in PyEval_EvalCode () at /usr/lib64/libpython3.9.so.1.0
#49 0x00007efc10131e5a in  () at /usr/lib64/libpython3.9.so.1.0
#50 0x00007efc10131f37 in  () at /usr/lib64/libpython3.9.so.1.0
#51 0x00007efc10134ad6 in PyRun_FileExFlags () at /usr/lib64/libpython3.9.so.1.0
#52 0x00007efc10134c6a in PyRun_SimpleFileExFlags () at /usr/lib64/libpython3.9.so.1.0
#53 0x00007efc1014fc3f in Py_RunMain () at /usr/lib64/libpython3.9.so.1.0
#54 0x00007efc101500f9 in Py_BytesMain () at /usr/lib64/libpython3.9.so.1.0
#55 0x00007efc0fdeee6b in __libc_start_main () at /lib64/libc.so.6
#56 0x0000555e3155208a in _start ()

@neteler
Copy link
Member Author

neteler commented Nov 25, 2020

Before going in that direction, try using latest wxPyhton 4.1.0 (wxWidgets 3.1). Ctypes should not be the problem here (in theory), since it's not related to any ctypes component.

I have the package "python-wxpython4" installed as well. Description: "wxPython4 is a is a new implementation of wxPython focused on improving speed, maintainability and extensibility. Just like "Classic" wxPython it wraps the wxWidgets C++ toolkit and provides access to the user interface portions of the wx API, enabling Python applications to have a GUI on Windows, Macs or Unix systems with a native look and feel and requiring very little (if any) platform specific code."

Fedora paclage: https://koji.fedoraproject.org/koji/buildinfo?buildID=1590928

Now, I wonder how to tell GRASS' configure about it (it doesn not come with wx-config)? Hints welcome.

@petrasovaa
Copy link
Contributor

Thanks @tmszi for the analysis, I assume this has been just fixed in wxWidgets/Phoenix#1847.

@petrasovaa
Copy link
Contributor

I have the package "python-wxpython4" installed as well. Description: "wxPython4 is a is a new implementation of wxPython focused on improving speed, maintainability and extensibility. Just like "Classic" wxPython it wraps the wxWidgets C++ toolkit and provides access to the user interface portions of the wx API, enabling Python applications to have a GUI on Windows, Macs or Unix systems with a native look and feel and requiring very little (if any) platform specific code."

You are using wxPython 4 already (wxPython 3 is old and without Py3 support). I was specifically asking about newest wxPython 4.1.0 (you are using 4.0.7) because it is using newer wxWidgets. However, if the problem was just fixed in wxPython couple days ago, that won't help...

@neteler
Copy link
Member Author

neteler commented Nov 26, 2020

According my testing problematic is calling PseudoDC.FindObjects() method.

Thanks for catching this, @tmszi. Would you mind to add a few lines here to explain how the debugger is attached to the GUI job?
https://grasswiki.osgeo.org/wiki/GRASS_Debugging#wxPython_GUI_debugging

@neteler
Copy link
Member Author

neteler commented Nov 26, 2020

Thanks @tmszi for the analysis, I assume this has been just fixed in wxWidgets/Phoenix#1847.

Excellent! Thanks for identifying this fix. I have downloaded the official python3-wxpython4 SRPM, patched it accordingly with this fix and rebuild the RPM (now here: python3-wxpython4-4.0.7-11.fc33.x86_64).

Works! Both d.mon and g.gui are back on Fedora 33.

I'll submit the patch to Fedora to get it included in the official RPM package. I suppose that nothing has to be done in GRASS GIS itself.

Update: done in https://bugzilla.redhat.com/show_bug.cgi?id=1901912

(patched in https://src.fedoraproject.org/rpms/python-wxpython4/c/f5471fb86aaae46a686b85c654fcbb98516355e6?branch=rawhide)

@tmszi
Copy link
Member

tmszi commented Nov 26, 2020

Thanks for catching this, @tmszi. Would you mind to add a few lines here to explain how the debugger is attached to the GUI job?
https://grasswiki.osgeo.org/wiki/GRASS_Debugging#wxPython_GUI_debugging

Yes, of course, I added an example to this subsection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working GUI wxGUI related
Projects
None yet
Development

No branches or pull requests

4 participants