Fix segfault/call on invalid pointer
ClosedPublic

Authored by sandsmark on Mar 27 2020, 1:57 PM.

Details

Summary

Quote from asan:

==161679==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7fa8cdcc193a bp 0x7ffe601e4a00 sp 0x7ffe601e48f0 T0)
==161679==The signal is caused by a READ memory access.
==161679==Hint: address points to the zero page.
    #0 0x7fa8cdcc1939 in Gwenview::AbstractImageViewPrivate::createAlphaBackgroundTexture() (/home/sandsmark/src/gwenview/build/bin/libgwenviewlib.so.5+0x108a939)
    #1 0x7fa8cdcc28b8 in Gwenview::AbstractImageViewPrivate::AbstractImageViewPrivate() (/home/sandsmark/src/gwenview/build/bin/libgwenviewlib.so.5+0x108b8b8)
    #2 0x7fa8cdca46a2 in Gwenview::AbstractImageView::AbstractImageView(QGraphicsItem*) ../lib/documentview/abstractimageview.cpp:145
    #3 0x7fa8cdd500a5 in Gwenview::RasterImageView::RasterImageView(QGraphicsItem*) ../lib/documentview/rasterimageview.cpp:194

We didn't set the AbstractImageView in AbstractImageViewPrivate early enough, and createAlphaBackgroundTexture() tried to call stuff on q.

Test Plan

No more crashing.

Diff Detail

Repository
R260 Gwenview
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
sandsmark requested review of this revision.Mar 27 2020, 1:57 PM
sandsmark created this revision.
sandsmark edited the summary of this revision. (Show Details)

This should be a fairly trivial and straightforward fix, fwiw. And without this and the other patches I can't really run gwenview with ubsan and asan.

ngraham accepted this revision.Apr 14 2020, 3:27 PM

Sorry for missing this.

This revision is now accepted and ready to land.Apr 14 2020, 3:27 PM
This revision was automatically updated to reflect the committed changes.

Sorry for missing this.

No problem, I probably should have just taken everything into one patch, or pushed the trivial stuff directly.