Bug 485407 - polkit-kde-agent crashes with nullptr
Summary: polkit-kde-agent crashes with nullptr
Status: NEEDSINFO BACKTRACE
Alias: None
Product: policykit-kde-agent-1
Classification: Plasma
Component: general (show other bugs)
Version: master
Platform: Arch Linux Linux
: NOR crash
Target Milestone: ---
Assignee: Unassigned bugs mailing-list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-04-12 01:24 UTC by jorgylbrandon
Modified: 2024-05-02 22:08 UTC (History)
10 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
GDB log (37.98 KB, text/plain)
2024-05-02 22:07 UTC, jorgylbrandon
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jorgylbrandon 2024-04-12 01:24:19 UTC
***
If you're not sure this is actually a bug, instead post about it at https://discuss.kde.org

If you're reporting a crash, attach a backtrace with debug symbols; see https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***

SUMMARY
The daemon launches and runs like expected but then silently crashes. The daemon isn't running in the background because ```appFilePath points to nullptr!```. I don't know what it means but it happens every time like clock work on both of my systems.

STEPS TO REPRODUCE
1. have it get executed during startup
2. launch an application with elevated privileges
3. launch a second application and see it not launch or show a banner across the top.

OBSERVED RESULT
the daemon runs once and silently closes in the background.

EXPECTED RESULT
The daemon runs every time there is a requested privalage escalation.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Hyprland / archlinux - 6.8.4-zen1-1-zen
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: qt6-wayland-6.7.0-1

ADDITIONAL INFORMATION
```[lee@Monolith ~]$ /usr/lib/polkit-kde-authentication-agent-1
New PolkitAgentListener  0x5bf069048780
Adding new listener  PolkitQt1::Agent::Listener(0x746b20008f90) for  0x5bf069048780
Listener online
Authentication agent result: true
Listener adapter polkit_qt_listener_initiate_authentication
GSimpleAsyncResult: 0x5bf06917c410
polkit_qt_listener_initiate_authentication callback for  0x5bf069048780
Initiating authentication
Action description has been found
kf.kirigami.platform: Failed to find a Kirigami platform plugin for style "Fusion"
User:  "unix-user:lee"
Trying again
REQUEST
Request:  "Password: "
Dialog accepted
COMPLETED
Completed:  true
Finishing obtaining privileges
Listener adapter polkit_qt_listener_initiate_authentication_finish
polkit_qt_listener_initiate_authentication_finish callback for  0x5bf069048780
Finish obtain authorization: true
Dialog cancelled
Finishing obtaining privileges
KCrash: appFilePath points to nullptr!
KCrash: Application '<unknown>' crashing... crashRecursionCounter = 2
Segmentation fault ```
Comment 1 hunterofgypsy 2024-04-17 04:38:56 UTC
I'm having the same issue. Polkit keeps crashing. I can run 

$ /usr/lib/polkit-kde-authentication-agent-1

it will allow one authentication and then crash

this is what the crash says:

$ /usr/lib/polkit-kde-authentication-agent-1
New PolkitAgentListener  0x5741f2fdc720
Adding new listener  PolkitQt1::Agent::Listener(0x5741f30612d0) for  0x5741f2fdc720
Listener online
Authentication agent result: true
Listener adapter polkit_qt_listener_initiate_authentication
GSimpleAsyncResult: 0x5741f2ff63d0
polkit_qt_listener_initiate_authentication callback for  0x5741f2fdc720
Initiating authentication
Action description has been found
User:  "unix-user:user"
Trying again
REQUEST
Request:  "Password: "
qrc:/qt/qml/org/kde/desktop/private/TextFieldContextMenu.qml:235:5: QML MenuItem: Binding loop detected for property "implicitWidth"
Dialog accepted
COMPLETED
Completed:  true
Finishing obtaining privileges
Listener adapter polkit_qt_listener_initiate_authentication_finish
polkit_qt_listener_initiate_authentication_finish callback for  0x5741f2fdc720
Finish obtain authorization: true
Dialog cancelled
Finishing obtaining privileges
KCrash: appFilePath points to nullptr!
KCrash: Application '<unknown>' crashing... crashRecursionCounter = 2
Segmentation fault
Comment 2 hunterofgypsy 2024-04-17 04:41:31 UTC
Furthermore, I have downgraded polkit to 6.0.0 and 6.0.1 and the behavior is identical, so there is some other package causing this.

This is on Artix Linux
Comment 3 continue2015 2024-04-17 14:12:41 UTC
I can confirm this bug in my computers running Hyprland(Arch Linux) and KDE Plasma(Arch Linux), and my friend's computer running KDE Plasma(Arch Linux). 
When using Hyprland, '/usr/lib/polkit-kde-authentication-agent-1' is start manually, and it failed with SIGSEGV after the first authentication, no matter the authentication itself is successful or not.
On Plasma it does fail, but silently, because in Plasma, polkit-kde-authentication-agent-1 is started by user service 'plasma-polkit-agent.service', and the service itself configured as 'Restart=on-failure', so the problem can be ignored.

I downloaded debug symbols and debugged with gdb, here is what I found.

Thread 1 "polkit-kde-auth" received signal SIGSEGV, Segmentation fault.
QObject::deleteLater (this=0x0)
    at /usr/src/debug/qt6-base/qtbase-everywhere-src-6.7.0/src/corelib/kernel/qobject.cpp:2456
2456	       Q_D(QObject);
(gdb) c
Continuing.

Thread 1 "polkit-kde-auth" received signal SIGSEGV, Segmentation fault.
0x0000722e4fcab32c in ?? () from /usr/lib/libc.so.6
(gdb) c

It seems that the problem is caused by qt 6.7.0 but not polkit-kde-agent, since the process failed in the function 'QObject::deleteLater()' when accessing a nullptr, and this code belongs to qt6-base but not the polkit component.

Further more, I found in qt 6.7.0, the commit https://github.com/qt/qtbase/commit/d50746e changed the way the 'QObject::deleteLater()' function works, so it might be a bug upstream caused by qt 6.7.0.
Comment 4 continue2015 2024-04-17 15:01:53 UTC
Workaround: For Arch Linux Users, downgrading to qt6-base 6.7.0beta3 can solve this problem. The problem appeared since qt6-base 6.7.0-rc1. I saw the latest commit added some code to avoid nullptr, and it might be fixed, we can just wait for the latest release of qt.
Comment 5 Matthew Moore 2024-04-19 02:05:01 UTC
I am having this problem, but on only one of my computers. I'm running Arch Linux on both machines, both have the same version of the qtbase, and the same version of polkit-kde-agent. They are basically two identical installations. Same package set, Same versions, Even the same theme and wallpaper. Two almost identical installations. The only real difference between these machines is, one is an Intel Laptop, and the other is an AMD Gaming PC. The AMD system has no problem. But the Intel system fails every single time. I can manually start /usr/lib/polkit-kde-authentication-agent-1 from a terminal. The moment i use it, it will authenticate once, and then crash.  The output it exactly as others have posted (See below).  Why it works on my AMD system, and Not my Intel system, is a bit strange. I would be curious how many people reporting this bug are on Intel systems vs AMD. That could be valuable information. 

$ /usr/lib/polkit-kde-authentication-agent-1
New PolkitAgentListener  0x5741f2fdc720
Adding new listener  PolkitQt1::Agent::Listener(0x5741f30612d0) for  0x5741f2fdc720
Listener online
Authentication agent result: true
Listener adapter polkit_qt_listener_initiate_authentication
GSimpleAsyncResult: 0x5741f2ff63d0
polkit_qt_listener_initiate_authentication callback for  0x5741f2fdc720
Initiating authentication
Action description has been found
User:  "unix-user:user"
Trying again
REQUEST
Request:  "Password: "
qrc:/qt/qml/org/kde/desktop/private/TextFieldContextMenu.qml:235:5: QML MenuItem: Binding loop detected for property "implicitWidth"
Dialog accepted
COMPLETED
Completed:  true
Finishing obtaining privileges
Listener adapter polkit_qt_listener_initiate_authentication_finish
polkit_qt_listener_initiate_authentication_finish callback for  0x5741f2fdc720
Finish obtain authorization: true
Dialog cancelled
Finishing obtaining privileges
KCrash: appFilePath points to nullptr!
KCrash: Application '<unknown>' crashing... crashRecursionCounter = 2
Segmentation fault
Comment 6 hunterofgypsy 2024-04-19 02:11:49 UTC
(In reply to Matthew Moore from comment #5)
> I am having this problem, but on only one of my computers. I'm running Arch
> Linux on both machines, both have the same version of the qtbase, and the
> same version of polkit-kde-agent. They are basically two identical
> installations. Same package set, Same versions, Even the same theme and
> wallpaper. Two almost identical installations. The only real difference
> between these machines is, one is an Intel Laptop, and the other is an AMD
> Gaming PC. The AMD system has no problem. But the Intel system fails every
> single time. I can manually start /usr/lib/polkit-kde-authentication-agent-1
> from a terminal. The moment i use it, it will authenticate once, and then
> crash.  The output it exactly as others have posted (See below).  Why it
> works on my AMD system, and Not my Intel system, is a bit strange. I would
> be curious how many people reporting this bug are on Intel systems vs AMD.
> That could be valuable information. 
> 
> $ /usr/lib/polkit-kde-authentication-agent-1
> New PolkitAgentListener  0x5741f2fdc720
> Adding new listener  PolkitQt1::Agent::Listener(0x5741f30612d0) for 
> 0x5741f2fdc720
> Listener online
> Authentication agent result: true
> Listener adapter polkit_qt_listener_initiate_authentication
> GSimpleAsyncResult: 0x5741f2ff63d0
> polkit_qt_listener_initiate_authentication callback for  0x5741f2fdc720
> Initiating authentication
> Action description has been found
> User:  "unix-user:user"
> Trying again
> REQUEST
> Request:  "Password: "
> qrc:/qt/qml/org/kde/desktop/private/TextFieldContextMenu.qml:235:5: QML
> MenuItem: Binding loop detected for property "implicitWidth"
> Dialog accepted
> COMPLETED
> Completed:  true
> Finishing obtaining privileges
> Listener adapter polkit_qt_listener_initiate_authentication_finish
> polkit_qt_listener_initiate_authentication_finish callback for 
> 0x5741f2fdc720
> Finish obtain authorization: true
> Dialog cancelled
> Finishing obtaining privileges
> KCrash: appFilePath points to nullptr!
> KCrash: Application '<unknown>' crashing... crashRecursionCounter = 2
> Segmentation fault

I'm on AMD/AMD, so that's not it. The guy above says downgrading QT-BASE to beta3 will resolve. I aliased /usr/lib/polkit-kde-authentication-agent-1 as polkitty as a workaround for the time being.
Comment 8 Fabian Arndt 2024-05-02 01:59:09 UTC
Please have a look at bug 485937.
Can  somebody check if the QT style is overridden or if forcing it to fusion fixes the issue?
Comment 9 jorgylbrandon 2024-05-02 22:07:31 UTC
Created attachment 169118 [details]
GDB log

This is my best attempt of a back trace, I hope it's useful.
Comment 10 jorgylbrandon 2024-05-02 22:08:52 UTC
This is my best attempt getting a backtrace. I hope you find this useful.