Bug 452834 - Segmentation fault when closing multiple windows
Summary: Segmentation fault when closing multiple windows
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: * Unknown (other bugs)
Version First Reported In: git master (please specify the git hash!)
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-21 20:47 UTC by Bourumir Wyngs
Modified: 2022-05-27 13:37 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
gdb backtrace (4.49 KB, text/plain)
2022-04-21 20:47 UTC, Bourumir Wyngs
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bourumir Wyngs 2022-04-21 20:47:58 UTC
Created attachment 148289 [details]
gdb backtrace

SUMMARY
When more than one window is used, closing windows one by one terminates Krita with segmentation fault. Segmentation fault message is visible in console and can be analyzed with gdb. Crash rather than normal termination may prevent saving state on exit.
***


STEPS TO REPRODUCE
1.  Start krita from the command line, so that the terminal output is visible.
2.  Open one picture.
3.  Open another picture in a new window, using Window -> New Window from menu.
4.  Close both windows, starting from the last opened window. Sometimes the crash happens when closing the first window, sometimes when another but I have never seen a clean exit at this point.

At this step Krita will terminate with segmentation fault message in console. Or, if running under gdb, the following message will appear:

Thread 1 "krita" received signal SIGSEGV, Segmentation fault.
KoToolProxy::priv (this=0x0) at kritadev/krita/libs/flake/KoToolProxy.cpp:495
495	    return d;


OBSERVED RESULT
Segmentation fault

EXPECTED RESULT
Normal exit

SOFTWARE/OS VERSIONS
Ubuntu Mate 20.04. 
Standard build as recommended in documentation.
Master branch commit 6419e038185a3377f638d26e34588a56c0f71cd8  .

ADDITIONAL INFORMATION
From the code analysis looks like the crash happens because 'this' is null in KisToolProxy::activateToolAction. The bug can be suppressed by adding check if (this == nullptr) return at the start of this method, but some more in depth analysis would probably be beneficial, maybe we should not get there starting from.
Comment 1 Lynx3d 2022-05-27 13:37:30 UTC
Git commit 805c9327fd55fcbbcce6fba6d15d719068cb8ab4 by Mathias Wein.
Committed on 27/05/2022 at 13:29.
Pushed by mwein into branch 'master'.

Fix crash when closing multiple main windows

There is a global state in KisAbstractInputAction that needs to be set
correctly whenever they are called.
(That entire tool code really could do with an overhaul...it wasn't
designed with multiple independent main windows in mind.)

M  +6    -0    libs/ui/input/kis_input_manager.cpp

https://invent.kde.org/graphics/krita/commit/805c9327fd55fcbbcce6fba6d15d719068cb8ab4