Bug 444567

Summary: KDevelop crashes when renaming a variable on an assert in BasicRefactoring::executeRenameAction
Product: [Applications] kdevelop Reporter: Jonathan Verner <jonathan.verner>
Component: generalAssignee: kdevelop-bugs-null
Status: RESOLVED FIXED    
Severity: crash Keywords: drkonqi
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In: 5.8.220400
Sentry Crash Report:
Attachments: New crash information added by DrKonqi

Description Jonathan Verner 2021-10-28 21:32:28 UTC
Application: kdevelop (5.6.40)

Qt Version: 5.15.3
Frameworks Version: 5.87.0
Operating System: Linux 5.11.0-38-generic x86_64
Windowing System: X11
Distribution: KDE neon User - Plasma 25th Anniversary Edition
DrKonqi: 5.23.2 [KCrashBackend]

-- Information about the crash:
- What I was doing when the application crashed:

I tried to rename a (python) variable.

The crash was due to the `BasicRefactoring::executeRenameAction` function calling
`decl.isValid()` while the DUChain is not read locked and then hitting an assert in
this method.

The reporter is unsure if this crash is reproducible.

-- Backtrace (Reduced):
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#5  0x00007f0db3c4e859 in __GI_abort () at abort.c:79
#6  0x00007f0db4091bd7 in qt_message_fatal (context=..., message=<synthetic pointer>...) at global/qlogging.cpp:1914
#7  QMessageLogger::fatal(char const*, ...) const (this=this@entry=0x7fff378e5f70, msg=msg@entry=0x7f0db439cea0 "ASSERT: \"%s\" in file %s, line %d") at global/qlogging.cpp:893
#8  0x00007f0db4090fe3 in qt_assert(char const*, char const*, int) (assertion=<optimized out>, file=<optimized out>, line=<optimized out>) at ../../include/QtCore/../../src/corelib/global/qlogging.h:90


Possible duplicates by query: bug 441058, bug 438433, bug 425994, bug 423651, bug 423123.

Reported using DrKonqi
Comment 1 Jonathan Verner 2021-10-28 21:32:29 UTC
Created attachment 142981 [details]
New crash information added by DrKonqi

DrKonqi auto-attaching complete backtrace.
Comment 2 Bug Janitor Service 2021-10-28 22:58:20 UTC
A possibly relevant merge request was started @ https://invent.kde.org/kdevelop/kdevelop/-/merge_requests/276
Comment 3 Igor Kushnir 2021-12-14 10:59:11 UTC
Git commit 08e4a17ab5fe58bb9f3ffbcca15244c75d1db714 by Igor Kushnir, on behalf of Jonathan L. Verner.
Committed on 14/12/2021 at 10:25.
Pushed by igorkushnir into branch 'master'.

Fix a crash when renaming a variable (in executeRenameAction)

When renaming a variable, the function `BasicRefactoring::executeRenameAction`
calls the `isValid` method of `IndexedDeclaration` which is documented to
require the DUChain to be read locked. However the function does no such
locking. This commit introduces a lock around the two calls.
FIXED-IN: 5.8.220400

M  +10   -5    kdevplatform/language/codegen/basicrefactoring.cpp

https://invent.kde.org/kdevelop/kdevelop/commit/08e4a17ab5fe58bb9f3ffbcca15244c75d1db714