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 crash when adding a raster with non-nearest neighbor default resampling #33711

Closed
nirvn opened this issue Jan 10, 2020 · 6 comments · Fixed by #34066
Closed

QGIS crash when adding a raster with non-nearest neighbor default resampling #33711

nirvn opened this issue Jan 10, 2020 · 6 comments · Fixed by #34066
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Crash/Data Corruption Rasters Related to general raster layer handling (not specific data formats) Regression Something which used to work, but doesn't anymore

Comments

@nirvn
Copy link
Contributor

nirvn commented Jan 10, 2020

Describe the bug

Just stumbled on a serious raster crasher, whereas if the default zoomed out resampling is set to anything but nearest neighbor, QGIS dies loading the raster.

How to Reproduce

  1. Launch QGIS
  2. Open the options dialog, go in the rendering section, and make sure zoomed out resampling combo box is set to average
  3. Close the options dialog
  4. Add the following raster dataset: https://www.licadho-cambodia.org/432.zip
  5. boom QGIS dies

QGIS and OS versions

Confirmed on linux and windows, QGIS 3.10 (LTR) and master.

Additional context

gdb output:

[Switching to Thread 0x7fff3cff9700 (LWP 12621)]
__memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:326
326	../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S: No such file or directory.
(gdb) where
#0  __memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:326
#1  0x00007ffff4ee099c in QgsGdalProvider::readBlock(int, QgsRectangle const&, int, int, void*, QgsRasterBlockFeedback*) (this=
    0x55555a5c71a0, bandNo=3, extent=..., pixelWidth=1674, pixelHeight=1674, data=0x7fff2079b7b0, feedback=0x55555b29a1e0)
    at /home/webmaster/dev/cpp/QGIS/src/core/providers/gdal/qgsgdalprovider.cpp:943
#2  0x00007ffff4ede9ee in QgsGdalProvider::block(int, QgsRectangle const&, int, int, QgsRasterBlockFeedback*)
    (this=0x55555a5c71a0, bandNo=3, extent=..., width=1674, height=1674, feedback=0x55555b29a1e0)
    at /home/webmaster/dev/cpp/QGIS/src/core/providers/gdal/qgsgdalprovider.cpp:672
#3  0x00007ffff5617b83 in QgsMultiBandColorRenderer::block(int, QgsRectangle const&, int, int, QgsRasterBlockFeedback*) (this=
    0x55555b928cb0, bandNo=1, extent=..., width=1674, height=1674, feedback=0x55555b29a1e0)
    at /home/webmaster/dev/cpp/QGIS/src/core/raster/qgsmultibandcolorrenderer.cpp:189
#4  0x00007ffff56127e5 in QgsBrightnessContrastFilter::block(int, QgsRectangle const&, int, int, QgsRasterBlockFeedback*)
    (this=0x55555a5bf7b0, bandNo=1, extent=..., width=1674, height=1674, feedback=0x55555b29a1e0)
    at /home/webmaster/dev/cpp/QGIS/src/core/raster/qgsbrightnesscontrastfilter.cpp:118
#5  0x00007ffff5614900 in QgsHueSaturationFilter::block(int, QgsRectangle const&, int, int, QgsRasterBlockFeedback*)
    (this=0x55555b3750f0, bandNo=1, extent=..., width=1674, height=1674, feedback=0x55555b29a1e0)
    at /home/webmaster/dev/cpp/QGIS/src/core/raster/qgshuesaturationfilter.cpp:123
#6  0x00007ffff5639c12 in QgsRasterResampleFilter::block(int, QgsRectangle const&, int, int, QgsRasterBlockFeedback*)
    (this=0x55555b4c0ec0, bandNo=1, extent=..., width=835, height=835, feedback=0x55555b29a1e0)
    at /home/webmaster/dev/cpp/QGIS/src/core/raster/qgsrasterresamplefilter.cpp:193
#7  0x00007ffff56099e5 in QgsRasterProjector::block(int, QgsRectangle const&, int, int, QgsRasterBlockFeedback*)
    (this=0x55555b37c5f0, bandNo=1, extent=..., width=835, height=835, feedback=0x55555b29a1e0)
    at /home/webmaster/dev/cpp/QGIS/src/core/raster/qgsrasterprojector.cpp:783
#8  0x00007ffff55daac5 in QgsRasterIterator::readNextRasterPartInternal(int, int&, int&, std::unique_ptr<QgsRasterBlock, std::default_delete<QgsRasterBlock> >*, int&, int&, QgsRectangle*)
    (this=0x7fff3cff73e0, bandNumber=1, nCols=@0x7fff3cff72e0: 835, nRows=@0x7fff3cff72e4: 835, block=0x7fff3cff7310, topLeftCol=@0x7fff3cff72e8: 0, topLeftRow=@0x7fff3cff72ec: 0, blockExtent=0x0) at /home/webmaster/dev/cpp/QGIS/src/core/raster/qgsrasteriterator.cpp:130
#9  0x00007ffff55da2b2 in QgsRasterIterator::readNextRasterPart(int, int&, int&, std::unique_ptr<QgsRasterBlock, std::default_delete<QgsRasterBlock> >&, int&, int&, QgsRectangle*)
    (this=0x7fff3cff73e0, bandNumber=1, nCols=@0x7fff3cff72e0: 835, nRows=@0x7fff3cff72e4: 835, block=std::unique_ptr<QgsRasterBlock> = {...}, topLeftCol=@0x7fff3cff72e8: 0, topLeftRow=@0x7fff3cff72ec: 0, blockExtent=0x0) at /home/webmaster/dev/cpp/QGIS/src/core/raster/qgsrasteriterator.cpp:80
#10 0x00007ffff56233e7 in QgsRasterDrawer::draw(QPainter*, QgsRasterViewPort*, QgsMapToPixel const*, QgsRasterBlockFeedback*)
    (this=0x7fff3cff73a8, p=0x55555b4bf6c0, viewPort=0x55555b3ea930, qgsMapToPixel=0x555556867d10, feedback=0x55555b29a1e0)
    at /home/webmaster/dev/cpp/QGIS/src/core/raster/qgsrasterdrawer.cpp:60
#11 0x00007ffff55fc8eb in QgsRasterLayerRenderer::render() (this=0x5555579554b0)
    at /home/webmaster/dev/cpp/QGIS/src/core/raster/qgsrasterlayerrenderer.cpp:264
#12 0x00007ffff516f39a in QgsMapRendererParallelJob::renderLayerStatic(LayerRenderJob&) (job=...)
    at /home/webmaster/dev/cpp/QGIS/src/core/qgsmaprendererparalleljob.cpp:353
@nirvn nirvn added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Jan 10, 2020
@nirvn
Copy link
Contributor Author

nirvn commented Jan 10, 2020

@nyalldawson , it might be a regression from your resampling work.

@gioman gioman added Crash/Data Corruption Rasters Related to general raster layer handling (not specific data formats) labels Jan 10, 2020
@nirvn
Copy link
Contributor Author

nirvn commented Jan 24, 2020

Confirmed to crash on both my windows (osgeo4w build) and linux (self-built) OSes.

@gioman gioman added the Regression Something which used to work, but doesn't anymore label Jan 24, 2020
@nirvn
Copy link
Contributor Author

nirvn commented Jan 27, 2020

Some more debugging information output (debug output from the QgsGdalProvider::readBlock(...) function):

src/core/providers/gdal/qgsgdalprovider.cpp:718 : (readBlock) [130ms] [thread:0x564f80b3b010] pixelWidth = 1674
src/core/providers/gdal/qgsgdalprovider.cpp:719 : (readBlock) [0ms] [thread:0x564f80b3b010] pixelHeight = 1674
src/core/providers/gdal/qgsgdalprovider.cpp:720 : (readBlock) [0ms] [thread:0x564f80b3b010] extent: 399940.0000000000000000,1390180.0000000000000000 : 509780.0000000000000000,1500020.0000000000000000
src/core/providers/gdal/qgsgdalprovider.cpp:724 : (readBlock) [0ms] [thread:0x564f80b3b010] transform : 399960
src/core/providers/gdal/qgsgdalprovider.cpp:724 : (readBlock) [0ms] [thread:0x564f80b3b010] transform : 10
src/core/providers/gdal/qgsgdalprovider.cpp:724 : (readBlock) [0ms] [thread:0x564f80b3b010] transform : 0
src/core/providers/gdal/qgsgdalprovider.cpp:724 : (readBlock) [0ms] [thread:0x564f80b3b010] transform : 1.5e+06
src/core/providers/gdal/qgsgdalprovider.cpp:724 : (readBlock) [0ms] [thread:0x564f80b3b010] transform : 0
src/core/providers/gdal/qgsgdalprovider.cpp:724 : (readBlock) [0ms] [thread:0x564f80b3b010] transform : -10
src/core/providers/gdal/qgsgdalprovider.cpp:751 : (readBlock) [0ms] [thread:0x564f80b3b010] extent: 399960.0000000000000000,1390200.0000000000000000 : 509760.0000000000000000,1500000.0000000000000000
src/core/providers/gdal/qgsgdalprovider.cpp:752 : (readBlock) [0ms] [thread:0x564f80b3b010] rasterExtent: 399960.0000000000000000,1390200.0000000000000000 : 509760.0000000000000000,1500000.0000000000000000
src/core/providers/gdal/qgsgdalprovider.cpp:788 : (readBlock) [0ms] [thread:0x564f80b3b010] top = 0 bottom = 1673 left = 0 right = 1673
src/core/providers/gdal/qgsgdalprovider.cpp:799 : (readBlock) [0ms] [thread:0x564f80b3b010] xRes = 65.6153 yRes = 65.6153 srcXRes = 10 srcYRes = -10
src/core/providers/gdal/qgsgdalprovider.cpp:855 : (readBlock) [0ms] [thread:0x564f80b3b010] srcTop = 0 srcBottom = 10979 srcLeft = 0 srcRight = 10979
src/core/providers/gdal/qgsgdalprovider.cpp:860 : (readBlock) [0ms] [thread:0x564f80b3b010] width = 1674 height = 1674 srcWidth = 10980 srcHeight = 10980
src/core/providers/gdal/qgsgdalprovider.cpp:876 : (readBlock) [0ms] [thread:0x564f80b3b010] tmpXMin = 399960 tmpYMax = 1.5e+06 tmpWidth = 1673 tmpHeight = 1673
QGIS died on signal 11Could not attach to process.  If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try

@nirvn
Copy link
Contributor Author

nirvn commented Jan 27, 2020

Here's the same debug info when loading a raster with nearest neighbor resampling (i.e. not leading to a crash):

src/core/providers/gdal/qgsgdalprovider.cpp:718 : (readBlock) [247ms] [thread:0x7f4cc4034f60] pixelWidth = 835
src/core/providers/gdal/qgsgdalprovider.cpp:719 : (readBlock) [0ms] [thread:0x7f4cc4034f60] pixelHeight = 835
src/core/providers/gdal/qgsgdalprovider.cpp:720 : (readBlock) [0ms] [thread:0x7f4cc4034f60] extent: 399960.0000000000000000,1390200.0000000000000000 : 509760.0000000000000000,1500000.0000000000000000
src/core/providers/gdal/qgsgdalprovider.cpp:724 : (readBlock) [0ms] [thread:0x7f4cc4034f60] transform : 399960
src/core/providers/gdal/qgsgdalprovider.cpp:724 : (readBlock) [0ms] [thread:0x7f4cc4034f60] transform : 10
src/core/providers/gdal/qgsgdalprovider.cpp:724 : (readBlock) [0ms] [thread:0x7f4cc4034f60] transform : 0
src/core/providers/gdal/qgsgdalprovider.cpp:724 : (readBlock) [0ms] [thread:0x7f4cc4034f60] transform : 1.5e+06
src/core/providers/gdal/qgsgdalprovider.cpp:724 : (readBlock) [0ms] [thread:0x7f4cc4034f60] transform : 0
src/core/providers/gdal/qgsgdalprovider.cpp:724 : (readBlock) [0ms] [thread:0x7f4cc4034f60] transform : -10
src/core/providers/gdal/qgsgdalprovider.cpp:751 : (readBlock) [0ms] [thread:0x7f4cc4034f60] extent: 399960.0000000000000000,1390200.0000000000000000 : 509760.0000000000000000,1500000.0000000000000000
src/core/providers/gdal/qgsgdalprovider.cpp:752 : (readBlock) [0ms] [thread:0x7f4cc4034f60] rasterExtent: 399960.0000000000000000,1390200.0000000000000000 : 509760.0000000000000000,1500000.0000000000000000
src/core/providers/gdal/qgsgdalprovider.cpp:788 : (readBlock) [0ms] [thread:0x7f4cc4034f60] top = 0 bottom = 834 left = 0 right = 834
src/core/providers/gdal/qgsgdalprovider.cpp:799 : (readBlock) [0ms] [thread:0x7f4cc4034f60] xRes = 131.497 yRes = 131.497 srcXRes = 10 srcYRes = -10
src/core/providers/gdal/qgsgdalprovider.cpp:855 : (readBlock) [0ms] [thread:0x7f4cc4034f60] srcTop = 0 srcBottom = 10979 srcLeft = 0 srcRight = 10979
src/core/providers/gdal/qgsgdalprovider.cpp:860 : (readBlock) [0ms] [thread:0x7f4cc4034f60] width = 835 height = 835 srcWidth = 10980 srcHeight = 10980
src/core/providers/gdal/qgsgdalprovider.cpp:876 : (readBlock) [0ms] [thread:0x7f4cc4034f60] tmpXMin = 399960 tmpYMax = 1.5e+06 tmpWidth = 835 tmpHeight = 835

Here, width == tmpWidth (835) whereas width != tmpWidth in the debug info from the scenario that crashes QGIS. @nyalldawson , is width != tmpWidth normal?

@elpaso
Copy link
Contributor

elpaso commented Jan 27, 2020

I can reproduce the crash on current master/linux.

@nirvn
Copy link
Contributor Author

nirvn commented Jan 27, 2020

I just checked against 3.10.2 on windows, it crashes there too.

nyalldawson added a commit to nyalldawson/QGIS that referenced this issue Jan 28, 2020
TODO: completely junk this inefficient secondary resampler and use GDAL's
resampling instead

Fixes qgis#33711
nyalldawson added a commit that referenced this issue Jan 28, 2020
TODO: completely junk this inefficient secondary resampler and use GDAL's
resampling instead

Fixes #33711
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 Rasters Related to general raster layer handling (not specific data formats) Regression Something which used to work, but doesn't anymore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants