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

QGIS crashes while calling readLayerXml() on a WMS layer on Windows #46741

Closed
2 tasks done
cxcandid opened this issue Jan 7, 2022 · 12 comments
Closed
2 tasks done

QGIS crashes while calling readLayerXml() on a WMS layer on Windows #46741

cxcandid opened this issue Jan 7, 2022 · 12 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! PyQGIS Related to the PyQGIS API

Comments

@cxcandid
Copy link

cxcandid commented Jan 7, 2022

What is the bug or the crash?

QGIS crashes while calling readLayerXml() on Windows.

Steps to reproduce the issue

Try the following code, which is part of the changeDataSource plugin, to reproduce the bug:

rasterLayer ... active WMS raster layer

from PyQt5.QtXml import *

rasterLayer = iface.activeLayer()

XMLDocument = QDomDocument("style")
XMLMapLayers = XMLDocument.createElement("maplayers")
XMLMapLayer = XMLDocument.createElement("maplayer")
context = QgsReadWriteContext()
rasterLayer.writeLayerXml(XMLMapLayer,XMLDocument, context)

#   XMLMapLayer.firstChildElement("datasource").firstChild().setNodeValue(newDatasource)
#   XMLMapLayer.firstChildElement("provider").firstChild().setNodeValue(newProvider)

XMLMapLayers.appendChild(XMLMapLayer)
XMLDocument.appendChild(XMLMapLayers)
rasterLayer.readLayerXml(XMLMapLayer, context) # <== QGIS crashes here

Versions

QGIS version
3.22.2-Białowieża
QGIS code revision
1601ec4
Qt version
5.15.2
Python version
3.9.5
GDAL/OGR version
3.4.0
PROJ version
8.2.0
EPSG Registry database version
v10.038 (2021-10-21)
GEOS version
3.10.0-CAPI-1.16.0
SQLite version
3.35.2
PDAL version
2.3.0
PostgreSQL client version
13.0
SpatiaLite version
5.0.1
QWT version
6.1.3
QScintilla2 version
2.11.5
OS version
Windows 10 Version 2009

Active Python plugins
db_manager
0.1.20
grassprovider
2.12.99
MetaSearch
0.3.5
processing
2.12.99
sagaprovider
2.12.99

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

  • I tried with a new QGIS profile

Additional context

Crash ID: cabb170ce9b4cbfc835aad0515873f11dc7a8376

Stack Trace

QgsDefaultRasterLayerLegend::createLayerTreeModelLegendNodes :
QgsLayerTreeModel::addLegendToLayer :
QgsLayerTreeModel::refreshLayerLegend :
QgsLayerTreeModel::layerLegendChanged :
QObject::qt_static_metacall :
QObject::qt_static_metacall :
QObject::qt_static_metacall :
QgsRasterLayer::setRendererForDrawingStyle :
QgsRasterLayer::setDataProvider :
QgsRasterLayer::readXml :
QgsMapLayer::readLayerXml :
PyInit__core :
PyArg_ParseTuple_SizeT :
PyEval_EvalFrameDefault :
PyObject_GC_Del :
PyEval_EvalCodeWithName :
PyEval_EvalCodeEx :
PyEval_EvalCode :
PyEval_GetBuiltins :
PyEval_GetBuiltins :
PyEval_EvalFrameDefault :
PyFloat_FromDouble :
PyEval_EvalFrameDefault :
PyObject_GC_Del :
PyFloat_FromDouble :
PyEval_EvalFrameDefault :
PyObject_GC_Del :
PyFloat_FromDouble :
PyEval_EvalFrameDefault :
PyFloat_FromDouble :
PyEval_EvalFrameDefault :
PyFloat_FromDouble :
PyEval_EvalFrameDefault :
PyFunction_Vectorcall :
PyFloat_FromDouble :
PyVectorcall_Call :
PyObject_Call :
PyInit__gui :
QWidget::event :
QFrame::event :
QAbstractScrollArea::event :
PyInit__gui :
QApplicationPrivate::notify_helper :
QApplication::notify :
QgsApplication::notify :
QCoreApplication::notifyInternal2 :
QSizePolicy::QSizePolicy :
QApplicationPrivate::notify_helper :
QApplication::notify :
QgsApplication::notify :
QCoreApplication::notifyInternal2 :
QGuiApplicationPrivate::processKeyEvent :
QWindowSystemInterface::sendWindowSystemEvents :
QEventDispatcherWin32::processEvents :
qt_plugin_query_metadata :
QEventLoop::exec :
QCoreApplication::exec :
main :
BaseThreadInitThunk :
RtlUserThreadStart :

QGIS Info
QGIS Version: 3.22.2-Bia?owie?a
QGIS code revision: 1601ec4
Compiled against Qt: 5.15.2
Running against Qt: 5.15.2
Compiled against GDAL: 3.4.0
Running against GDAL: 3.4.0

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

@cxcandid cxcandid added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Jan 7, 2022
@gioman gioman added the PyQGIS Related to the PyQGIS API label Jan 7, 2022
@roya0045
Copy link
Contributor

roya0045 commented Jan 9, 2022

The title and descriptions mentions the crash on write but the code snippets mentions a crash on read. Also is there a stacktrace or anything more?

@gioman gioman added the Feedback Waiting on the submitter for answers label Jan 9, 2022
@cxcandid
Copy link
Author

cxcandid commented Jan 9, 2022

@roya0045 this was a mistake, should be readLayerXml() of course.
BTW: the code is taken from changeDataSource plugin, which fails in QGIS 3.22.2 as well.
In QGIS 3.20.3 everything is fine. I can add a stack trace, but I guess it won't be of much help.

@cxcandid cxcandid changed the title QGIS crashes while calling writeLayerXml() QGIS crashes while calling readLayerXml() Jan 9, 2022
@gioman gioman removed the Feedback Waiting on the submitter for answers label Jan 9, 2022
@cxcandid
Copy link
Author

cxcandid commented Jan 9, 2022

@roya0045 in case it might be helpful after all, I added the stack trace to the original report.

@cxcandid
Copy link
Author

QGIS still crashes in 3.22.3 while trying to change a raster datasource with changeDataSource plugin.

@elpaso
Copy link
Contributor

elpaso commented Jan 24, 2022

Cannot reproduce on linux/master.

immagine

@gioman gioman added the Feedback Waiting on the submitter for answers label Jan 24, 2022
@cxcandid cxcandid changed the title QGIS crashes while calling readLayerXml() QGIS crashes while calling readLayerXml() on Windows Jan 24, 2022
@cxcandid
Copy link
Author

cxcandid commented Feb 4, 2022

I installed QGIS 3.22.3 on a brand new Lenovo Notebook with Windows 10 Home (20H2) and received the same crash.
Can someone please confirm this QGIS 3.22.x bug on Windows?

BTW: I'm using OSGeo4W installer

@github-actions
Copy link

The QGIS project highly values your report and would love to see it addressed. However, this issue has been left in feedback mode for the last 14 days and is being automatically marked as "stale".
If you would like to continue with this issue, please provide any missing information or answer any open questions. If you could resolve the issue yourself meanwhile, please leave a note for future readers with the same problem and close the issue.
In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this issue.
If there is no further activity on this issue, it will be closed in a week.

@github-actions github-actions bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Feb 19, 2022
@cxcandid
Copy link
Author

This issue still exists in QGIS 3.24.0 (Windows 10).
QGIS throws "Windows fatal exception: access violation".

@github-actions github-actions bot removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Feb 21, 2022
@gioman
Copy link
Contributor

gioman commented Feb 21, 2022

This issue still exists in QGIS 3.24.0 (Windows 10).

@cxcandid no crash here (master, Win10) with the code you provided.

@cxcandid
Copy link
Author

cxcandid commented Feb 21, 2022

QGIS crashes if raster layer source is WMS or XYZ. With file based images it's ok.

@gioman gioman removed the Feedback Waiting on the submitter for answers label Feb 21, 2022
@gioman gioman changed the title QGIS crashes while calling readLayerXml() on Windows QGIS crashes while calling readLayerXml() on a WMS layer on Windows Feb 21, 2022
@gioman
Copy link
Contributor

gioman commented Feb 21, 2022

QGIS crashes if raster layer source is WMS or XYZ

Confirmed.

@cxcandid
Copy link
Author

Issue is solved in QGIS 3.24.1 Rev. 5709b82.

Thanks a lot!

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! PyQGIS Related to the PyQGIS API
Projects
None yet
Development

No branches or pull requests

4 participants