https://bugs.kde.org/show_bug.cgi?id=442896

Igor Kushnir <igor...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Version Fixed In|                            |5.13.231200
             Status|ASSIGNED                    |RESOLVED
      Latest Commit|                            |https://invent.kde.org/kdev
                   |                            |elop/kdevelop/-/commit/07c1
                   |                            |748bf71a3b6b2f8182146672ddc
                   |                            |7558a032c
         Resolution|---                         |FIXED

--- Comment #3 from Igor Kushnir <igor...@gmail.com> ---
Git commit 07c1748bf71a3b6b2f8182146672ddc7558a032c by Igor Kushnir.
Committed on 15/09/2023 at 14:50.
Pushed by igorkushnir into branch 'master'.

Revert "types: Remove unfilterable debug output"

TypeSystem::registerTypeClassInternal() is called in the constructor and
TypeSystem::unregisterTypeClassInternal() - in the destructor of each
global-variable object declared via the REGISTER_TYPE macro.
registerTypeClassInternal() does not log any messages, therefore these
global variables are constructed before the function-local static
QLoggingCategory constant LANGUAGE. So the global variables are
destroyed after LANGUAGE (in the reverse order of the completion of
constructors). unregisterTypeClassInternal() attempts to log a message
via qCDebug(LANGUAGE) when the function-local LANGUAGE is already
destroyed. This is undefined behavior, which in practice causes the
following two issues:
1. When KDevelop is started normally and
   kdevplatform.language.debug=true, the "Unregistering type class"
   messages lack the usual prefix "kdevplatform.language: ".
2. When KDevelop exits immediately without showing the UI (because of
   a command-line option such as --help or --list-sessions) and
   kdevplatform.language.debug=false (the default), the disabled debug
   messages clutter the program output (curiously, they do start with
   the "kdevplatform.language: " prefix).

Log a matching "Registering type class" message via qCDebug(LANGUAGE) in
registerTypeClassInternal() to complete the constructor of LANGUAGE
before the constructors of global variables that use LANGUAGE in their
destructors. This eliminates the undefined behavior and its two
practical consequences.

The reverted commit's message contains:
  This is printed before Qt categorized logging is properly set up and
  thus may be printed even though it's technically disabled via filters.
I haven't encountered the referenced issue during my testing of this
commit. Perhaps the implementation of Qt categorized logging has
improved since then (2017) and is now reliably set up in time. If not
and the original issue resurfaces, the qCDebug(LANGUAGE) line in
registerTypeClassInternal() can be replaced with the line `LANGUAGE();`,
which does not log anything but still initializes the function-local
static QLoggingCategory constant.

This reverts commit a5eac48a83fc6e443459e7e045b9230b011c537b.
FIXED-IN: 5.13.231200

M  +1    -0    kdevplatform/language/duchain/types/typeregister.cpp

https://invent.kde.org/kdevelop/kdevelop/-/commit/07c1748bf71a3b6b2f8182146672ddc7558a032c

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to