Bug 513423

Summary: A crash in python debugger variable widget.
Product: [Developer tools] kdev-python Reporter: JATothrim <jarmo.tiitto>
Component: generalAssignee: JATothrim <jarmo.tiitto>
Status: RESOLVED FIXED    
Severity: crash CC: igorkuo, mail
Priority: NOR    
Version First Reported In: 6.0.251180   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 6.0.251201
Sentry Crash Report:

Description JATothrim 2025-12-16 05:42:50 UTC
SUMMARY

A crash in KDevelop python debugger variable widget:
0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007ffff5a989d3 in __pthread_kill_internal (threadid=<optimized out>, signo=6) at pthread_kill.c:89
#2  0x00007ffff5a3e3a0 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007ffff5a2557a in __GI_abort () at abort.c:77
#4  0x00007ffff5e9a41f in std::__glibcxx_assert_fail
    (file=file@entry=0x7fff9beab1d8 "/usr/include/c++/15.2.1/array", line=line@entry=210, function=function@entry=0x7fff9beab930 "constexpr std::array<_Tp, _Nm>::value_type& std::array<_Tp, _Nm>::operator[](size_type) [with _Tp = Python::VariableController::Collection; long unsigned int _Nm = 4; reference = Python::VariableContr"..., condition=condition@entry=0x7fff9beab1c5 "__n < this->size()") at /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/assert_fail.cc:41
#5  0x00007fff9be86339 in std::array<Python::VariableController::Collection, 4ul>::operator[] (this=<optimized out>, __n=<optimized out>) at /usr/include/c++/15.2.1/array:208
#6  std::array<Python::VariableController::Collection, 4ul>::operator[] (this=<optimized out>, __n=<optimized out>) at /usr/include/c++/15.2.1/array:208
#7  Python::VariableController::pendingRequests (this=<optimized out>, adjust=1, index=<optimized out>) at /usr/src/debug/kdevelop-python/kdev-python-25.12.0/debugger/variablecontroller.cpp:23

STEPS TO REPRODUCE
1. Use non en_US locale
2. Start debugging
3. Try expand a variable section which is name has been localized

OBSERVED RESULT

Instant crash.

EXPECTED RESULT

Expanding the variable sections works, regardless of the locale used.

SOFTWARE/OS VERSIONS
KDevelop: 6.4.251200 (25.12.0)
KDE Frameworks: 6.21.0
Qt: 6.10.1,  6.10.1
Arch Linux (Xcb)
Build ABI: x86_64-little_endian-lp64


ADDITIONAL INFORMATION

There is a ongoing, partly related MR https://invent.kde.org/kdevelop/kdevelop/-/merge_requests/848/commits that provides some work to help resolve this bug also in kdev-python.

A workaround in meanwhile is to run kdevelop using en_US locale.
Comment 1 Igor Kushnir 2025-12-16 16:05:19 UTC
Does this crash occur in kdev-python version 6.3.250802? (the value of a field "Version First Reported In")
If not, I suggest implementing a quick workaround that can be cherry-picked into the stable branch first. A better solution can wait for later.
Comment 2 JATothrim 2025-12-16 22:26:18 UTC
(In reply to Igor Kushnir from comment #1)
> Does this crash occur in kdev-python version 6.3.250802? (the value of a
> field "Version First Reported In")
> If not, I suggest implementing a quick workaround that can be cherry-picked
> into the stable branch first. A better solution can wait for later.

No.
The crash is present since the first tagged release of kdevpdb (-ng) v25.11.80 The translated strings between kdev-python and KDevelop don't match, as in kdev-python the strings are not translated, leading to the crash.
Comment 3 Bug Janitor Service 2025-12-16 22:32:47 UTC
A possibly relevant merge request was started @ https://invent.kde.org/kdevelop/kdev-python/-/merge_requests/61
Comment 4 JATothrim 2025-12-17 22:06:34 UTC
Git commit 49cc1d9606be9ec4c33c169111f21903c734bf7f by Jarmo Tiitto.
Committed on 17/12/2025 at 18:39.
Pushed by brauch into branch 'master'.

kdevpdb: fix a crash caused by a localization mismatch

It turns out that KDevelop's and kdevpdb's i18n() translated strings can
mismatch. The VariableController::fetch*() methods pass a seemingly
translated string to the enumerateNamespace() method, which assigns it
to a Namespace instance. This string is then passed to the
variableCollection()->locals() call to access the KDevelop::Locals
instances that have already been initialized. Locals::updateLocals()
then calls createVariable(), which either aborts or crashes because it
cannot find the index of the i18n("Locals") named section of the
KDevelop::Locals instance in the m_collections array.

The crash or Q_ASSERT() failure occurred because the i18n("Locals")
resulted in an untranslated string within the plugin. However, on the
KDevelop side, the string was translated, resulting in a mismatch.
Therefore, KDevelop::VariableCollection::locals(ns->name) returned a
new, unrelated KDevelop::Locals instance, and our createVariable()
cannot find an index for it.

This can be fixed by storing a pointer to the KDevelop::Locals instance
in the Namespace struct instead, and using this member to call
updateLocals(). This resolves the crash because a Locals instance from
the m_collections array is now guaranteed to be used. The last parameter
of enumerateNamespace() is therefore redundant and has been removed. The
less important qCDebug(KDEV_PYTHON_VARIABLECONTROLLER) debug print
statement has been modified so that this fix can be implemented.
FIXED-IN: 6.0.251201

M  +11   -9    debugger/variablecontroller.cpp
M  +7    -2    debugger/variablecontroller.h

https://invent.kde.org/kdevelop/kdev-python/-/commit/49cc1d9606be9ec4c33c169111f21903c734bf7f
Comment 5 Igor Kushnir 2025-12-18 16:54:23 UTC
Git commit 34619137263acd0d2d65a8eb92f47d7231718457 by Igor Kushnir, on behalf of Jarmo Tiitto.
Committed on 18/12/2025 at 16:53.
Pushed by igorkushnir into branch 'release/25.12'.

kdevpdb: fix a crash caused by a localization mismatch

It turns out that KDevelop's and kdevpdb's i18n() translated strings can
mismatch. The VariableController::fetch*() methods pass a seemingly
translated string to the enumerateNamespace() method, which assigns it
to a Namespace instance. This string is then passed to the
variableCollection()->locals() call to access the KDevelop::Locals
instances that have already been initialized. Locals::updateLocals()
then calls createVariable(), which either aborts or crashes because it
cannot find the index of the i18n("Locals") named section of the
KDevelop::Locals instance in the m_collections array.

The crash or Q_ASSERT() failure occurred because the i18n("Locals")
resulted in an untranslated string within the plugin. However, on the
KDevelop side, the string was translated, resulting in a mismatch.
Therefore, KDevelop::VariableCollection::locals(ns->name) returned a
new, unrelated KDevelop::Locals instance, and our createVariable()
cannot find an index for it.

This can be fixed by storing a pointer to the KDevelop::Locals instance
in the Namespace struct instead, and using this member to call
updateLocals(). This resolves the crash because a Locals instance from
the m_collections array is now guaranteed to be used. The last parameter
of enumerateNamespace() is therefore redundant and has been removed. The
less important qCDebug(KDEV_PYTHON_VARIABLECONTROLLER) debug print
statement has been modified so that this fix can be implemented.
FIXED-IN: 6.0.251201
(cherry picked from commit 49cc1d9606be9ec4c33c169111f21903c734bf7f)

M  +11   -9    debugger/variablecontroller.cpp
M  +7    -2    debugger/variablecontroller.h

https://invent.kde.org/kdevelop/kdev-python/-/commit/34619137263acd0d2d65a8eb92f47d7231718457