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

Dbmanager causes QGIS to crash when trying to open Postgres db #38393

Closed
rduivenvoorde opened this issue Aug 20, 2020 · 18 comments · Fixed by #39465
Closed

Dbmanager causes QGIS to crash when trying to open Postgres db #38393

rduivenvoorde opened this issue Aug 20, 2020 · 18 comments · Fixed by #39465
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Crash/Data Corruption DB Manager Relating to the DB Manager core plugin Regression Something which used to work, but doesn't anymore

Comments

@rduivenvoorde
Copy link
Contributor

To reproduce:
(I'm on Debian testing here, QGIS master self compiled)

select postgis_full_version() gives me
POSTGIS="3.0.2 r2fb2a18" [EXTENSION] PGSQL="120" GEOS="3.8.1-CAPI-1.13.3" PROJ="7.1.0" LIBXML="2.9.10" LIBJSON="0.15" LIBPROTOBUF="1.3.3" WAGYU="0.4.3 (Internal)" (core procs from "3.0.0 r17983" need upgrade)

select version() gives me
PostgreSQL 12.3 (Debian 12.3-1+b1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 9.3.0-13) 9.3.0, 64-bit

  • create a fresh profiles-path (qgis --profiles-path /tmp/foo)
  • create a local Postgres db connection (plain passwords)
  • test with normal QGIS Postgres connection manager if you are able to see the schema's and tables: OK
  • test with Browser: OK
  • open DB Manager
  • open PostGIS node (still ok)
  • click 'localhost' node: CRASH

stacktrace below:

../src/core/qgsdataitem.cpp:956 : (~QgsDataCollectionItem) [20ms] mName = localhost mPath = pg:/localhost
../src/core/qgsdataitem.cpp:266 : (~QgsDataItem) [0ms] mName = localhost mPath = pg:/localhost mChildren.size() = 0
../src/core/qgsdataitem.cpp:266 : (~QgsDataItem) [0ms] mName = OpenStreetMap mPath = xyz:/OpenStreetMap mChildren.size() = 0
../src/core/qgsdataitem.cpp:956 : (~QgsDataCollectionItem) [0ms] mName = localhost mPath = pg:/localhost
../src/core/qgsdataitem.cpp:266 : (~QgsDataItem) [0ms] mName = localhost mPath = pg:/localhost mChildren.size() = 0
../src/core/qgsdataitem.cpp:266 : (~QgsDataItem) [0ms] mName = OpenStreetMap mPath = xyz:/OpenStreetMap mChildren.size() = 0
QGIS died on signal 11[New LWP 120929]
[New LWP 120930]
[New LWP 120931]
[New LWP 120932]
[New LWP 120934]
[New LWP 120935]
[New LWP 120936]
[New LWP 120937]
[New LWP 120944]
[New LWP 120945]
[New LWP 120950]
[New LWP 120951]
[New LWP 120967]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007f0355df92c7 in __GI___wait4 (pid=120984, stat_loc=0x7ffdbada0114, options=0, usage=0x0) at ../sysdeps/unix/sysv/linux/wait4.c:27
27 ../sysdeps/unix/sysv/linux/wait4.c: No such file or directory.
[Current thread is 1 (Thread 0x7f034501af40 (LWP 120921))]
#0 0x00007f0355df92c7 in _GI___wait4 (pid=120984, stat_loc=0x7ffdbada0114, options=0, usage=0x0) at ../sysdeps/unix/sysv/linux/wait4.c:27
#1 0x00005635749cc257 in qgisCrash(int) (signal=11) at ../src/app/main.cpp:349
status = 32514
pidstr = "--pid=120921\000\177\000\000\020\377ٺ\375\177\000\000\224\210\365\340\002\177\000"
gdbpid = 120984
exename = "/home/richard/bin/qgis
/master/debug/bin/qgis", '\000' <repeats 35 times>, "\322\b{5V\000\000\300\256\067\350\002\177\000\000\000\000\000\000\000\000\000\000\300\070\035\350\002\177\000\000\000\000\000\000\000\000\000\000\230m\360D\003\177\000\000\000\000\000\000\000\000\000\000\322\b{5V\000\000\030\000ں\375\177\000\000\000}\246\370\031\354R.\020", '\000' <repeats 15 times>, "\300\357\361D\003\177\000\000\000}\246\370\031\354R.\300\322\005{5V\000\000\340"...
len = 45
#2 0x00007f0355d69e30 in () at /lib/x86_64-linux-gnu/libc.so.6
#3 __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:65
#4 0x00007f02e81ee3b9 in () at /usr/lib/python3/dist-packages/PyQt5/QtCore.cpython-38-x86_64-linux-gnu.so
#5 0x00007f02e0f589c7 in () at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0
#6 0x00007f02e0f59817 in _PyObject_MakeTpCall () at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0
#7 0x00007f02e0f34cd3 in () at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0
#8 0x00007f02e0f328f9 in _PyEval_EvalFrameDefault () at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0
#9 0x00007f02e1031ebf in _PyEval_EvalCodeWithName () at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0
#10 0x00007f02e0f58b61 in _PyFunction_Vectorcall () at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0
#11 0x00007f02e0f5a79a in () at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0
#12 0x00007f02e0f34c4d in () at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0
#13 0x00007f02e0f328f9 in _PyEval_EvalFrameDefault () at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0
#14 0x00007f02e1031ebf in _PyEval_EvalCodeWithName () at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0
#15 0x00007f02e0f58b61 in _PyFunction_Vectorcall () at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0
#16 0x00007f02e0f5a79a in () at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0
#17 0x00007f02e0f34c4d in () at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0
#18 0x00007f02e0f328f9 in _PyEval_EvalFrameDefault () at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0
#19 0x00007f02e0f2a073 in () at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0
#20 0x00007f02e0f5a79a in () at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0
#21 0x00007f02e0f34c4d in () at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0
#22 0x00007f02e0f328f9 in _PyEval_EvalFrameDefault () at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0
#23 0x00007f02e1031ebf in _PyEval_EvalCodeWithName () at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0
#24 0x00007f02e0f58b61 in _PyFunction_Vectorcall () at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0
#25 0x00007f02e0f5a79a in () at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0
#26 0x00007f02e0f34c4d in () at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0
#27 0x00007f02e0f328f9 in _PyEval_EvalFrameDefault () at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0
#28 0x00007f02e0f2a073 in () at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0
#29 0x00007f02e0f5a713 in () at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0
#30 0x00007f02e0f5913c in PyVectorcall_Call () at /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0
#31 0x00007f0344f07dda in () at /usr/lib/python3/dist-packages/sip.cpython-38-x86_64-linux-gnu.so
#32 0x00007f0344f08009 in () at /usr/lib/python3/dist-packages/sip.cpython-38-x86_64-linux-gnu.so
#33 0x00007f02e81498bf in () at /usr/lib/python3/dist-packages/PyQt5/QtCore.cpython-38-x86_64-linux-gnu.so
#34 0x00007f02e8265a60 in () at /usr/lib/python3/dist-packages/PyQt5/QtCore.cpython-38-x86_64-linux-gnu.so
#35 0x00007f03592fa92a in QTreeViewPrivate::layout(int, bool, bool) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#36 0x00007f03592fd504 in QTreeViewPrivate::expand(int, bool) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#37 0x00007f03592fedc6 in QTreeViewPrivate::expandOrCollapseItemAtPos(QPoint const&) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#38 0x00007f03593015ad in QTreeView::mousePressEvent(QMouseEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#39 0x00007f02e07bd003 in () at /usr/lib/python3/dist-packages/PyQt5/QtWidgets.cpython-38-x86_64-linux-gnu.so
#40 0x00007f035907552e in QWidget::event(QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#41 0x00007f035911cd4e in QFrame::event(QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#42 0x00007f02e07beec3 in () at /usr/lib/python3/dist-packages/PyQt5/QtWidgets.cpython-38-x86_64-linux-gnu.so
#43 0x00007f035859a87b in QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#44 0x00007f035903502e in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#45 0x00007f035903a781 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#46 0x00007f0356c84e51 in QgsApplication::notify(QObject*, QEvent*) (this=0x7ffdbada31c0, receiver=0x56357afec2a0, event=0x7ffdbada2220) at ../src/core/qgsapplication.cpp:444
done = true
FUNCTION = "notify"
#47 0x00007f035859ab62 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#48 0x00007f0359039696 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer&, bool, bool) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#49 0x00007f035908d95e in () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#50 0x00007f03590907ae in () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#51 0x00007f035903503f in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#52 0x00007f0356c84e51 in QgsApplication::notify(QObject*, QEvent*) (this=0x7ffdbada31c0, receiver=0x5635776781f0, event=0x7ffdbada25b0) at ../src/core/qgsapplication.cpp:444
done = true
FUNCTION = "notify"
#53 0x00007f035859ab62 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#54 0x00007f035896244b in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#55 0x00007f0358938bfb in QWindowSystemInterface::sendWindowSystemEvents(QFlagsQEventLoop::ProcessEventsFlag) () at /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#56 0x00007f030941db6a in () at /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#57 0x00007f034e4885fd in g_main_context_dispatch () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#58 0x00007f034e488880 in () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#59 0x00007f034e48890f in g_main_context_iteration () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#60 0x00007f03585f02ff in QEventDispatcherGlib::processEvents(QFlagsQEventLoop::ProcessEventsFlag) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#61 0x00007f03585994db in QEventLoop::exec(QFlagsQEventLoop::ProcessEventsFlag) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#62 0x00007f03585a1782 in QCoreApplication::exec() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#63 0x00005635749d3a2f in main(int, char**) (argc=3, argv=0x7ffdbada44d8) at ../src/app/main.cpp:1637
preApplicationLogMessages = {<QList> = {<QListSpecialMethods> = {}, {p = {static shared_null = {ref = {atomic = {_q_value = {<std::__atomic_base> = {static _S_alignment = 4, _M_i = -1}, }}}, alloc = 0, begin = 0, end = 0, array = {0x0}}, d = 0x563576c355d0}, d = 0x563576c355d0}}, }
FUNCTION = "main"
mySnapshotFileName = {static null = {}, d = 0x7f035867b8a0 QArrayData::shared_null}
configLocalStorageLocation = {static null = {}, d = 0x563576c379d0}
profileName = {static null = {}, d = 0x563576c37320}
mySnapshotWidth = 800
mySnapshotHeight = 600
myHideSplash = false
settingsMigrationForce = false
mySkipVersionCheck = false
hideBrowser = false
myRestoreDefaultWindowState = false
myRestorePlugins = true
myCustomization = true
dxfOutputFile = {static null = {}, d = 0x7f035867b8a0 QArrayData::shared_null}
dxfSymbologyMode = QgsDxfExport::SymbolLayerSymbology
dxfScale = 50000
dxfEncoding = {static null = {}, d = 0x5635749deb00 <main::{lambda()#2}::operator()() const::qstring_literal>}
dxfMapTheme = {static null = {}, d = 0x7f035867b8a0 QArrayData::shared_null}
dxfExtent = {mXmin = 0, mYmin = 0, mXmax = 0, mYmax = 0}
takeScreenShots = false
screenShotsPath = {static null = {}, d = 0x7f035867b8a0 QArrayData::shared_null}
screenShotsCategories = 0
myInitialExtent = {static null = {}, d = 0x7f035867b8a0 QArrayData::shared_null}
translationCode = {static null = {}, d = 0x563576c3d9d0}
authdbdirectory = {static null = {}, d = 0x7f035867b8a0 QArrayData::shared_null}
pythonfile = {static null = {}, d = 0x7f035867b8a0 QArrayData::shared_null}
customizationfile = {static null = {}, d = 0x563577baa150}
globalsettingsfile = {static null = {}, d = 0x563576c2fb10}
openClProgramFolder = {static null = {}, d = 0x7f035867b8a0 QArrayData::shared_null}
args = {<QList> = {<QListSpecialMethods> = {}, {p = {static shared_null = {ref = {atomic = {_q_value = {<std::__atomic_base> = {static _S_alignment = 4, _M_i = -1}, }}}, alloc = 0, begin = 0, end = 0, array = {0x0}}, d = 0x563576c35970}, d = 0x563576c35970}}, }
myUseGuiFlag = true
rootProfileFolder = {static null = {}, d = 0x563576c37e20}
manager = { = {}, static staticMetaObject = {d = {superdata = {direct = 0x7f0358819260 QObject::staticMetaObject}, stringdata = 0x7f03576253c0 <qt_meta_stringdata_QgsUserProfileManager>, data = 0x7f0357625440 <qt_meta_data_QgsUserProfileManager>, static_metacall = 0x7f03567241c8 <QgsUserProfileManager::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)>, relatedMetaObjects = 0x0, extradata = 0x0}}, mWatchProfiles = false, mWatcher = std::unique_ptr = {get() = 0x0}, mRootProfilePath = {static null = {}, d = 0x563576c37e20}, mUserProfile = std::unique_ptr = {get() = 0x0}, mSettings = std::unique_ptr = {get() = 0x563576c37480}}
profile = 0x563576c3cdb0
profileFolder = {static null = {}, d = 0x563576c38f20}
myApp = { = {}, static staticMetaObject = {d = {superdata = {direct = 0x7f0359529160 QApplication::staticMetaObject}, stringdata = 0x7f0357611fc0 <qt_meta_stringdata_QgsApplication>, data = 0x7f03576121c0 <qt_meta_data_QgsApplication>, static_metacall = 0x7f035670a3c4 <QgsApplication::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)>, relatedMetaObjects = 0x0, extradata = 0x0}}, static QGIS_ORGANIZATION_NAME = 0x7f0357758522 "QGIS", static QGIS_ORGANIZATION_DOMAIN = 0x7f0357758527 "qgis.org", static QGIS_APPLICATION_NAME = 0x7f0357758530 "QGIS3", static mFileOpenEventReceiver31500 = 0x563577c349e0, static mInitialized31500 = true, static mRunningFromBuildDir31500 = false, static sMaxThreads31500 = -1, mIconCache = {d = 0x563576a4eb60}, mCursorCache = {d = 0x563577ec59e0}, mQgisTranslator = 0x563576dfb9d0, mQtTranslator = 0x563576dc0340, mDataItemProviderRegistry = 0x5635771b6be0, mAuthManager = 0x563577213410, mApplicationMembers = 0x563576d590b0, static sApplicationMembers = 0x0, static sAuthManager = 0x0}
settings = { = {}, static staticMetaObject = {d = {superdata = {direct = 0x7f0358819260 QObject::staticMetaObject}, stringdata = 0x7f0357621100 <qt_meta_stringdata_QgsSettings>, data = 0x7f0357621140 <qt_meta_data_QgsSettings>, static_metacall = 0x7f03567200d0 <QgsSettings::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)>, relatedMetaObjects = 0x0, extradata = 0x0}}, mUserSettings = 0x563576cd8330, mGlobalSettings = 0x56357703d4c0, mUsingGlobalArray = false}
libPaths = {<QList> = {<QListSpecialMethods> = {}, {p = {static shared_null = {ref = {atomic = {_q_value = {<std::__atomic_base> = {static _S_alignment = 4, M_i = -1}, }}}, alloc = 0, begin = 0, end = 0, array = {0x0}}, d = 0x563577be79b0}, d = 0x563577be79b0}}, }
relLibPath = {static null = {}, d = 0x563577ba0940}
customizationsettings = 0x563577bcc860
systemEnvVars = {d = 0x563576ff1260}
useCustomVars = false
desiredStyle = {static null = {}, d = 0x5635749df920 <main::{lambda()#42}::operator()() const::qstring_literal>}
theme = {static null = {}, d = 0x7f035867b8a0 QArrayData::shared_null}
activeStyleName = {static null = {}, d = 0x56357702a530}
mySplashPath = {static null = {}, d = 0x7f0357759680 <QgsApplication::splashPath()::{lambda()#1}::operator()() const::qstring_literal>}
myPixmap =
w = 600
h = 300
mypSplash = 0x5635772418f0
qgis = 0x563577c349e0
sigwatch = { = {}, static staticMetaObject = {d = {superdata = {direct = 0x7f0358819260 QObject::staticMetaObject}, stringdata = 0x563574a203c0 <qt_meta_stringdata_UnixSignalWatcher>, data = 0x563574a20480 <qt_meta_data_UnixSignalWatcher>, static_metacall = 0x5635749da924 <UnixSignalWatcher::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)>, relatedMetaObjects = 0x0, extradata = 0x0}}, d_ptr = 0x563577baab00}
retval = 1956774144
[Inferior 1 (process 120921) detached]
gdb returned 0
/home/richard/bin/qgis: line 7: 120921 Aborted /home/richard/bin/qgis
/master/debug/bin/qgis "$@"

@rduivenvoorde rduivenvoorde added Bug Either a bug report, or a bug fix. Let's hope for the latter! Crash/Data Corruption DB Manager Relating to the DB Manager core plugin labels Aug 20, 2020
@gioman gioman added the Regression Something which used to work, but doesn't anymore label Aug 20, 2020
@nyalldawson
Copy link
Collaborator

I also see this crash -- it's caused by #38262

@elpaso
Copy link
Contributor

elpaso commented Aug 21, 2020

@nyalldawson @rduivenvoorde I tried but I can't reproduce.

@3nids do you see anything wrong in #38262 ?

@rduivenvoorde
Copy link
Contributor Author

rduivenvoorde commented Aug 21, 2020

I did do some further testing, to me it looks like th 'enumValue'-function is the culprit?

The following all works in the python console:

settings = QgsSettings()
settings.beginGroup(u"/%s/%s" % ('/PostgreSQL/connections', 'localhost'))
print(QgsDataSourceUri.SslPrefer)
print(QgsDataSourceUri.SslMode.SslPrefer) # I first thought THIS may be the issue...
# both printing 0 

But both

settings.enumValue("sslmode", QgsDataSourceUri.SslPrefer)
# or
settings.enumValue("sslmode", QgsDataSourceUri.SslMode.SslPrefer)

lead to an immidiate QGIS crash

I tried to set a 0 as default, but that has typing errors:

settings.enumValue("sslmode", 0)

Traceback (most recent call last):
  File "/usr/lib/python3.8/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "/home/richard/bin/qgis_/master/debug/share/qgis/python/qgis/core/additions/qgssettings.py", line 41, in _qgssettings_enum_value
    meta_enum = metaEnumFromValue(enumDefaultValue)
  File "/home/richard/bin/qgis_/master/debug/share/qgis/python/qgis/core/additions/metaenum.py", line 30, in metaEnumFromValue
    return metaEnumFromType(enumValue.__class__, baseClass, raiseException)
  File "/home/richard/bin/qgis_/master/debug/share/qgis/python/qgis/core/additions/metaenum.py", line 44, in metaEnumFromType
    raise TypeError("enumClass is an int, while it should be an enum")
TypeError: enumClass is an int, while it should be an enum

@elpaso
Copy link
Contributor

elpaso commented Aug 21, 2020

It works for me.

immagine

@rduivenvoorde
Copy link
Contributor Author

Mmm, Tested on a Windows laptop here with osgeo4w: QGIS code revision 0bd81d27c6 Cannot reproduce it there

The I trashed my build dir on my work/build laptop AND my install dirs and tried again: still crashing.
See if others with the setup below can reproduce:

QGIS version 3.15.0-Master QGIS code revision d1c45f8
Compiled against Qt 5.14.2 Running against Qt 5.14.2
Compiled against GDAL/OGR 3.1.2 Running against GDAL/OGR 3.1.2
Compiled against GEOS 3.8.1-CAPI-1.13.3 Running against GEOS 3.8.1-CAPI-1.13.3
Compiled against SQLite 3.33.0 Running against SQLite 3.33.0
PostgreSQL Client Version 12.4 (Debian 12.4-1) SpatiaLite Version 4.3.0a
QWT Version 6.1.4 QScintilla2 Version 2.11.2
Compiled against PROJ 7.1.0 Running against PROJ Rel. 7.1.0, August 1st, 2020
OS Version Debian GNU/Linux bullseye/sid This copy of QGIS writes debugging output.

@rduivenvoorde
Copy link
Contributor Author

I tried to catch the exception by doing this in QtCreator, but (see screendump) it is not something I can debug... To me it looks like something is indeed going wrong within the python/c++ world around getting the key/value from some settings object.

Screenshot-20200825131818-1610x1018

But this is going over my head, so I do not think I can be helpfull in this...

@espinafre
Copy link
Contributor

espinafre commented Aug 25, 2020

Watching. I'm also getting this crash, and manually changing /usr/share/qgis/python/plugins/db_manager/db_plugins/postgis/plugin.py , line 87, from

sslmode = settings.enumValue("sslmode", QgsDataSourceUri.SslPrefer)

to

sslmode = settings.value("sslmode", QgsDataSourceUri.SslPrefer, type=int)

effectively reverting #38262 makes it work again for me. It had crashed on me when connecting with a configured pg_service.

@ghtmtt
Copy link
Contributor

ghtmtt commented Sep 3, 2020

I can confirm. I'm on Debian sid. Can I be more helpful?

@3nids
Copy link
Member

3nids commented Sep 8, 2020

Investigating this.
I could reproduce the crash

For me, settings.enumValue("sslmode", QgsDataSourceUri.SslPrefer) crashes with SIP 4.19.17 but not on 4.19.21.

But doing:

idx = QgsDataSourceUri.staticMetaObject.indexOfEnumerator(QgsDataSourceUri.SslMode.__name__)
me = QgsDataSourceUri.staticMetaObject.enumerator(idx)
print(me.isValid())

does crash for me on any sip version.

Actually calling any method on the meta enum leads to crash (isValid, name, valueToKey). I have identified a crash in the past (https://github.com/qgis/QGIS/blob/master/python/core/additions/qgssettings.py#L48). I tried but we cannot make a deep copy on meta enums.

I would need to investigate a bit more, but I suspect PyQt is also involved in the issue.

@elpaso
Copy link
Contributor

elpaso commented Sep 8, 2020

@3nids thank you for looking at this! I suspected there was a SIP issue. I tested SIP 4.19.19 here with no crashes.

@rduivenvoorde
Copy link
Contributor Author

rduivenvoorde commented Sep 8, 2020

Just tested 'sip -V' returns 4.19.24 with me (and crashing)

Would it be helpfull to have that SIP version in the About box (where all those versions are)?

(and also thanks from me! These are hard things to investigate/fix)

@3nids
Copy link
Member

3nids commented Sep 8, 2020

Just tested 'sip -V' returns 4.19.24 with me (and crashing)

what crashes? settings.enumValue("sslmode", QgsDataSourceUri.SslPrefer) or the snippet or both?

Would it be helpfull to have that SIP version in the About box

Yes!

@rduivenvoorde
Copy link
Contributor Author

Just tested 'sip -V' returns 4.19.24 with me (and crashing)
what crashes? settings.enumValue("sslmode", QgsDataSourceUri.SslPrefer) or the snippet or both?

Both:

settings = QgsSettings()
settings.enumValue("sslmode", QgsDataSourceUri.SslPrefer)
# crash

and

idx = QgsDataSourceUri.staticMetaObject.indexOfEnumerator(QgsDataSourceUri.SslMode.__name__)
me = QgsDataSourceUri.staticMetaObject.enumerator(idx)
# still ok
print(me.isValid())
# crash

and

settings = QgsSettings()
settings.beginGroup(u"/%s/%s" % ('/PostgreSQL/connections', 'localhost'))
print(QgsDataSourceUri.SslPrefer)
print(QgsDataSourceUri.SslMode.SslPrefer) # I first thought THIS may be the issue...
# still ok both printing 0 
settings.enumValue("sslmode", QgsDataSourceUri.SslPrefer)
# crash

@3nids
Copy link
Member

3nids commented Sep 8, 2020

There is something wrong about accessing the meta enum from static meta object I guess.
Running:

me = metaEnumFromType(QgsDataSourceUri.SslMode)
print(me.isValid())

leads to a crash after ~7 iterations for me...

@3nids
Copy link
Member

3nids commented Sep 8, 2020

I sent a request on PyQt mailing list (https://www.riverbankcomputing.com/pipermail/pyqt/2020-September/043153.html) but I have little hope this leads to a solution.

@elpaso do you see any harm in reverting the commit causing the issue?

@elpaso
Copy link
Contributor

elpaso commented Sep 10, 2020

I sent a request on PyQt mailing list (https://www.riverbankcomputing.com/pipermail/pyqt/2020-September/043153.html) but I have little hope this leads to a solution.

@elpaso do you see any harm in reverting the commit causing the issue?

I think the question is if my commit #38262 is a correct usage of the new API or not.

If it is not correct you may revert it and explain how the original issue could be solved without using the enumValue API.

If it is correct then we have a problem with the new enum API and we should fix or revert that API.

The rationale is that we will have eventually have more and more adoption of the new enum API by plugin writers and if that API leads to random crashes it can be a real pain for everyone.

@rnanclares
Copy link

Same problem here with Pop_OS! 20.04 and master.
QGIS Master 3.15 QGIS code revision | 1387621

@engingem
Copy link

I have same issue on latest nightly master build with MacOS Catalina.

QGIS version: 3.15.0 (qgis_nightly_master_20201008_122909.dmg | 08-Oct-2020 19:35)
QGIS code revision: 29f657d
OS Version: macOS 10.15.7

Apple crash log

Process: QGIS [72464]

Path: /Applications/QGIS.app/Contents/MacOS/QGIS
Identifier: org.qgis.qgis3
Version: 3.15.0 (3.15.0 [])
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: QGIS [72464]
User ID: 502

Date/Time: 2020-10-12 11:01:05.344 +0100
OS Version: Mac OS X 10.15.7 (19H2)
Report Version: 12

System Integrity Protection: enabled

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY

Application Specific Information:
abort() called
QGIS(72464,0x11438cdc0) malloc: *** error for object 0x115770813: pointer being freed was not allocated

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff6c82933a __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff6c8e5e60 pthread_kill + 430
2 libsystem_c.dylib 0x00007fff6c7b0808 abort + 120
3 libsystem_malloc.dylib 0x00007fff6c8a650b malloc_vreport + 548
4 libsystem_malloc.dylib 0x00007fff6c8a940f malloc_report + 151
5 org.qt-project.QtCore 0x00000001110762ad QMetaEnum::name() const + 77
6 QtCore.so 0x000000013995f5c7 meth_QMetaEnum_isValid(_object*, _object*) + 87
7 libpython3.7m.dylib 0x000000013941b9d3 _PyMethodDef_RawFastCallKeywords + 387
8 libpython3.7m.dylib 0x000000013941ae26 _PyCFunction_FastCallKeywords + 38
9 libpython3.7m.dylib 0x00000001394cef15 call_function + 213
10 libpython3.7m.dylib 0x00000001394ca41e _PyEval_EvalFrameDefault + 20894

nyalldawson added a commit to nyalldawson/QGIS that referenced this issue Oct 19, 2020
This reverts commit 26e9ec9.

It results in unfixable crashes on many platforms, likely due to some
issue in sip itself

Fixes qgis#38393, reopens qgis#38245

The original bug (being asked twice for credentials) is preferable
over a hard crash
nyalldawson added a commit that referenced this issue Oct 22, 2020
This reverts commit 26e9ec9.

It results in unfixable crashes on many platforms, likely due to some
issue in sip itself

Fixes #38393, reopens #38245

The original bug (being asked twice for credentials) is preferable
over a hard crash
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 DB Manager Relating to the DB Manager core plugin Regression Something which used to work, but doesn't anymore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants