Bug report #20029

SQL query including "row_number" on a virtual layer crashes QGIS

Added by Gus Tech about 6 years ago. Updated almost 6 years ago.

Status:Closed
Priority:High
Assignee:Hugo Mercier
Category:Virtual Layers
Affected QGIS version:3.2.3 Regression?:No
Operating System:Windows 10 Easy fix?:No
Pull Request or Patch supplied:No Resolution:no timely feedback
Crashes QGIS or corrupts data:Yes Copied to github as #:27851

Description

User Feedback

I was trying this short SQL script on a PostGIS layer in the DB Manager:

select id, gov_na, row_number() over (partition by gov_na)
from admin.villages

The script works fine in PgAdmin III but keeps craching QGIS 3.2.3

Report Details

Crash ID: a7b3e03b393d182a60ed1a144378006767517e21

Stack Trace

QBasicMutex::unlockInternal :
QgsTask::processSubTasksForTermination :
QgsTask::cancel :
PyInit__core :
PyCFunction_FastCallDict :
PyObject_GenericGetAttr :
PyEval_EvalFrameDefault :
PyFunction_FastCallDict :
PyObject_CallFunctionObjArgs :
PyObject_Call :
PyInit_sip :
std::basic_string<char,std::char_traits<char>,std::allocator<char> >::shrink_to_fit :
std::_String_alloc<std::_String_base_types<char,std::allocator<char> > >::~_String_alloc<std::_String_base_types<char,std::allocator<char> > > :
QgsTask::subTaskStatusChanged :
QMetaCallEvent::placeMetaCall :
QObject::event :
std::_String_alloc<std::_String_base_types<char,std::allocator<char> > >::~_String_alloc<std::_String_base_types<char,std::allocator<char> > > :
QApplicationPrivate::notify_helper :
QApplication::notify :
QgsApplication::notify :
QCoreApplication::notifyInternal2 :
QCoreApplicationPrivate::sendPostedEvents :
qt_plugin_query_metadata :
QEventDispatcherWin32::processEvents :
CallWindowProcW :
DispatchMessageW :
QEventDispatcherWin32::processEvents :
qt_plugin_query_metadata :
QEventLoop::exec :
QCoreApplication::exec :
main :
BaseThreadInitThunk :
RtlUserThreadStart :

QGIS Info
QGIS Version: 3.2.3-Bonn
QGIS code revision: 9b176802e5
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


Related issues

Duplicated by QGIS Application - Bug report #20047: SQL queries on virtual layers frequently crashes QGIS Closed 2018-10-08

History

#1 Updated by Giovanni Manghi about 6 years ago

  • Priority changed from Normal to High
  • Subject changed from SQL script including row_number crashes QGIS to SQL query including "row_number" crashes QGIS
  • Status changed from Open to Feedback

This happens regardless of the table used in the query? Does the same on 2.18?

#2 Updated by Gus Tech about 6 years ago

Giovanni Manghi wrote:

This happens regardless of the table used in the query? Does the same on 2.18?

Actually, apologies for not mentioning that this is happening to a virtual layer in a QGIS project. Working on the DB directly returns the expected result whether it's 3.2.3 or 2.18.24.

In QGIS 3.2.3, running the query on a virtual layer in a QGIS project crashes the software, in QGIS 2.18.24, it returns the following error:
Query execution error on CREATE TEMP VIEW _tview AS select id, gov_na, row_number() over (partition by gov_na)
from villages: 1 - near "(": syntax error

#3 Updated by Giovanni Manghi about 6 years ago

  • Status changed from Feedback to Open
  • Subject changed from SQL query including "row_number" crashes QGIS to SQL query including "row_number" on a virtual layer crashes QGIS
  • Category changed from DB Manager to Virtual Layers

#4 Updated by Alessandro Pasotti about 6 years ago

  • Duplicated by Bug report #20047: SQL queries on virtual layers frequently crashes QGIS added

#5 Updated by Hugo Mercier about 6 years ago

  • Assignee set to Hugo Mercier

I indeed have a crash, under Windows only.

I think #19271 is the same problem.

#6 Updated by Nyall Dawson about 6 years ago

For reference - I spent some time looking at this one and the root cause is that an exception raised in the virtual layer provider is never caught (even though the code is in place to do this and it works on other platforms). It's only reproducible on windows.

#7 Updated by Hugo Mercier about 6 years ago

I'm struggling with visual studio. Do you remember exactly what exception was it ?

#8 Updated by Hugo Mercier about 6 years ago

I actually have a different stack trace

Stack Trace

QCoreApplication::postEvent :
qt_qFindChildren_helper :
QMetaObject::activate :
QgsTask::statusChanged moc_qgstaskmanager.cpp:197
QgsTask::processSubTasksForTermination qgstaskmanager.cpp:292
QgsTask::terminated qgstaskmanager.cpp:331
QgsTask::start qgstaskmanager.cpp:77
QgsTaskRunnableWrapper::run qgstaskmanager.cpp:350
QThreadPoolPrivate::reset :
QThread::start :
BaseThreadInitThunk :
RtlUserThreadStart :

QGIS Info
QGIS Version: 3.3.0-Master
QGIS code revision: 2aef195527
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.16299

#9 Updated by Hugo Mercier about 6 years ago

When I set breakpoints on exception raises with visual studio, I cannot reproduce the error. Looks like a synchronisation problem ...

#10 Updated by Giovanni Manghi about 6 years ago

  • Status changed from Open to Feedback

Please try on QGIS 3.4.1, if the issue is still valid change the affected version, thanks.

#11 Updated by Jürgen Fischer almost 6 years ago

  • Status changed from Feedback to Closed
  • Resolution set to no timely feedback

Bulk closing 82 tickets in feedback state for more than 90 days affecting an old version. Feel free to reopen if it still applies to a current version and you have more information that clarify the issue.

Also available in: Atom PDF