Ticket #2358 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

Segfault in swq_select_finish_summarize

Reported by: gagern Owned by: mloskot
Priority: normal Milestone: 1.5.2
Component: OGR_SF Version: 1.5.0
Severity: normal Keywords: ogrsql
Cc: warmerdam

Description

I hit this while using qgis, when I tried to classify attributes from a newly created vector layer with unsaved features and therefore empty attribute table in the file. This backtrace is from gdal 1.3.1, but I could reproduce it with 1.5.0 as well.

#0  0xb7ba67c4 in swq_select_finish_summarize (select_info=0x96b47d0) at swq.c:2233
#1  0xb7b37ecb in OGRGenSQLResultsLayer::PrepareSummary (this=0x96d74c0) at ogr_gensql.cpp:507
#2  0xb7b38b1c in OGRGenSQLResultsLayer::GetFeature (this=0x96d74c0, nFID=0) at ogr_gensql.cpp:725
#3  0xb7b38bcc in OGRGenSQLResultsLayer::GetNextFeature (this=0x96d74c0) at ogr_gensql.cpp:682
#4  0xb7b45273 in OGR_L_GetNextFeature (hLayer=0x96d74c0) at ogrlayer.cpp:446
#5  0xb5d2f873 in QgsOgrProvider::getUniqueValues (this=0x9693ea0, index=0, uniqueValues=@0xbfed1810)
    at /var/tmp/portage/sci-geosciences/qgis-0.10.0/work/qgis_0.10.0/src/providers/ogr/qgsogrprovider.cpp:1284

Reason seems to be that select_info->column_summary == NULL in swq_select_finish_summarize because column_summary gets allocated in swq_select_summarize when the first row of the result is processed, but OGRGenSQLResultsLayer::PrepareSummary never calls that function if there are no data rows.

I'm not sure what correct behaviour should be, probably an empty result set. Definitely not a crash.

Attachments

ticket2358.patch Download (0.5 KB) - added by gagern 4 years ago.
Patch skipping sort for empty result set
gdal-2358-reproduce-test.tar.bz2 Download (1.2 KB) - added by mloskot 4 years ago.
Simple test that reproduces QGIS steps and confirms the segmentation fault in OGR SQL engine (see README)

Change History

Changed 4 years ago by gagern

Patch skipping sort for empty result set

Changed 4 years ago by mloskot

  • owner changed from warmerdam to mloskot
  • status changed from new to assigned
  • milestone set to 1.6.0

I'm taking this ticket.

Changed 4 years ago by warmerdam

  • cc warmerdam added
  • keywords ogrsql added
  • component changed from default to OGR_SF

Mateusz,

I'm marking this as milestone 1.5.2. Please try to introduce a test in the autotest for this, likely in autotest/ogr/ogr_sql_test.py.

Thanks,

Changed 4 years ago by warmerdam

  • milestone changed from 1.6.0 to 1.5.2

Changed 4 years ago by mloskot

  • status changed from assigned to closed
  • resolution set to fixed

Fixed in trunk (r14426) and branches/1.5 (r14427)

Changed 4 years ago by mloskot

FYI, when fixing the segfault issue, I've noticed that the OGR provider in QGIS causes memory leak. I've submitted bug ticket:  http://trac.osgeo.org/qgis/ticket/1083

Changed 4 years ago by mloskot

Simple test that reproduces QGIS steps and confirms the segmentation fault in OGR SQL engine (see README)

Note: See TracTickets for help on using tickets.