Bug report #19455

Add MSSQL layer to canvas crashes QGIS3.2

Added by Liam Caffrey over 4 years ago. Updated about 4 years ago.

Category:Data Provider/MSSQL
Affected QGIS version:3.2 Regression?:No
Operating System:Windows 10.0.17134 Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed/implemented
Crashes QGIS or corrupts data:Yes Copied to github as #:27283


This issue appears to be similar to a previous problem #12324 on QGIS 2.8 Wien

User Feedback

Add MSSQL layer to canvas and pan the canvas around. QGIS crashes. Alternatively, add 1 layer, then without interacting with the canvas, add a second layer, QGIS crashes.

Report Details

Crash ID: 5bfd6ac6f67d8a578b91a0865116ad7a62cabaea

Stack Trace

RtlEnterCriticalSection :
ODBCSetTryWaitValue :
LockHandle :
SQLGetStmtAttrW :
QSqlDatabase::open :
sourceSelectProviders :
sourceSelectProviders :
QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator :
QgsVectorLayerFeatureSource::getFeatures :
QgsVectorLayerLabelProvider::registerFeature :
QgsMapRendererCustomPainterJob::doRender :
QgsMapRendererCustomPainterJob::staticRender :
QgsLayoutItemAttributeTable::maximumNumberOfFeatures :
QThreadPoolPrivate::reset :
QThread::start :
BaseThreadInitThunk :
RtlUserThreadStart :

QGIS Version: 3.2.0-Bonn
QGIS code revision: bc43194061
Compiled against Qt: 5.9.2
Running against Qt: 5.9.2
Compiled against GDAL: 2.2.4
Running against GDAL: 2.2.4

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

Database Engine
Microsoft SQL Server 2012 (SP4) (KB4018073) - 11.0.7001.0 (X64) Aug 15 2017 10:23:29 Copyright (c) Microsoft Corporation Standard Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) (Hypervisor)

Here is a simple MRE, run this code against your database. Navigate to it in QGIS and "Add selected layer(s) to canvas". Just pan around a bit and QGIS crashes.
IF OBJECT_ID('dbo.[qgis_temp_2]') IS NOT NULL drop table dbo.[qgis_temp_2];
CREATE TABLE dbo.[qgis_temp_2]
,[the_geom] [geometry] NULL

the_points as
select cast(1 as int) as OBJECTID, geometry::STPointFromText('POINT (-8.317927 53.301678)', 4326) as the_geom union all
select cast(2 as int) as OBJECTID, geometry::STPointFromText('POINT (-8.317833 53.301747)', 4326) as the_geom union all
select cast(3 as int) as OBJECTID, geometry::STPointFromText('POINT (-8.242390 53.313442)', 4326) as the_geom
insert into dbo.qgis_temp_2 (OBJECTID, the_geom)
select OBJECTID, the_geom
from the_points;

I am snookered now. Most of my spatial is in MSSQL. No option in DBManager for MSSQL, and separately, as a workaround, I am having trouble connecting to my SQL Server instance from Postgres via Foreign Tables and via FreeTDS/tsql!! Lots of hoops to jump through for MSSQL users. :-(


#1 Updated by Jürgen Fischer over 4 years ago

  • Description updated (diff)

#2 Updated by Jürgen Fischer over 4 years ago

  • Assignee deleted (Liam Caffrey)

#3 Updated by Nyall Dawson about 4 years ago

  • Status changed from Open to Feedback

Should be fixed in 3.3 master - please test

#4 Updated by Liam Caffrey about 4 years ago

I just tested as per above. It doesn't crash 3.3 master now. Also works with larger data sets from MSSQL. Looks good. Tnx.

#5 Updated by Giovanni Manghi about 4 years ago

  • Resolution set to fixed/implemented
  • Status changed from Feedback to Closed

Also available in: Atom PDF