Check whether m_walker is not 0
AbandonedPublic

Authored by rempt on Nov 8 2017, 1:10 PM.

Details

Reviewers
poke1024
dkazakov
Group Reviewers
Krita
Summary

This should help with https://bugs.kde.org/show_bug.cgi?id=386279

Since the m_walker can be set to zero, and since it is a shared pointer, and we should always check shared pointers before dereferencing, we should check m_walker before using it.

Also, remove a rather strangely phrased sentence that doesn't add much to the console log report.

Diff Detail

Repository
R37 Krita
Lint
Lint Skipped
Unit
Unit Tests Skipped
rempt created this revision.Nov 8 2017, 1:10 PM
dkazakov requested changes to this revision.Nov 8 2017, 4:10 PM

There should be a safe assert instead. There is no case when the walker can become null in any valid execution path. If it is null, it can lead to deadlock easily.

What is the test case to reproduce this bug? Is there a backtrace of other threads?

This revision now requires changes to proceed.Nov 8 2017, 4:10 PM
rempt added a comment.Nov 8 2017, 4:17 PM

I also had a version with a safe assert, but... a shared pointer should always be checked anyway. The original bug report has a full backtrace of all threads. It looks a bit weird because it's from OSX, but that shouldn't be too much of a problem.

We should check shared pointers if and only if there is a valid execution path that can lead to a state when shared pointer is null. Otherwise, a safe assert with a recovery procedure should be used. In this very case, shared pointer may become null only in case of a very dangerous race condition bug, caused by my recent refactoring (most probably).

KIS_SAFE_ASSERT_RECOVER_RETURN() will do exactly the same thing as your patch does, but will also help me to find out what is wrong there.

Technically, one should not try to continue working with this bug happening, it can cause a total deadlock with inability to save your work.

Hi @dkazakov, I cannot reproduce this reliably, it happens randomly but fairly often (like once every one or two weeks) on any of my Macs (iMac and MacBooks) while drawing wildly around over the whole canvas (nothing special, i.e. some non-specific 10 px brush on a 4000 x 4000 canvas).

One backtrace is here: https://bugsfiles.kde.org/attachment.cgi?id=108602

Here, thread 11 crashes at kis_base_rects_walker.h:198 with KERN_INVALID_ADDRESS at 0x0000000000000038.

Technically, one should not try to continue working with this bug happening, it can cause a total deadlock with inability to save your work.

I can subscribe to that. By the way, it seems that every time I get the console warnings, that something is wrong with the walker hierarchy, I always get this crash.

rempt abandoned this revision.Jan 23 2019, 8:57 AM
Restricted Application added a reviewer: Krita. · View Herald TranscriptJan 23 2019, 8:57 AM
Restricted Application added a project: Krita. · View Herald Transcript