This repository was archived by the owner on Aug 26, 2026. It is now read-only.
fix(accounts): guard userList against unavailable Accounts service - #23
Closed
zccrs wants to merge 1 commit into
Closed
fix(accounts): guard userList against unavailable Accounts service#23zccrs wants to merge 1 commit into
zccrs wants to merge 1 commit into
Conversation
DAccountsManager::userList() dereferences a null QArrayDataPointer (SIGSEGV) when org.freedesktop.Accounts is not available because QDBusPendingReply::value() is accessed without checking service registration or reply validity. The crash is triggered via Treeland's Helper::init -> UserModel singleton during compositor startup (QML UserModel at src/greeter/usermodel.cpp:64) when dde-system-daemon fails to activate (Go concurrent map panic). Add isServiceRegistered guard before DBus call, check isError/isValid, and iterate over a copied value with empty-path guard to avoid demarshall failures. Fixes SIGSEGV (exit 139) on treeland startup when Accounts service is down. Log: fix accounts userList SIGSEGV when service unavailable PMS: TASK-393829
Contributor
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: zccrs The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideHardens DAccountsManager::userList() against an unavailable Accounts service and invalid D-Bus payloads, preventing the startup-time SIGSEGV while preserving normal user enumeration. Sequence diagram for guarded Accounts user listingsequenceDiagram
participant UserModel
participant DAccountsManager
participant DBus as QDBusConnection
participant Accounts as org.freedesktop.Accounts
UserModel->>DAccountsManager: userList()
DAccountsManager->>DBus: isServiceRegistered(org.freedesktop.Accounts)
alt service unavailable
DBus-->>DAccountsManager: false
DAccountsManager-->>UserModel: DUnexpected ServiceUnknown
else service available
DBus-->>DAccountsManager: true
DAccountsManager->>Accounts: listCachedUsers()
DAccountsManager->>Accounts: waitForFinished()
alt reply.isError() or !reply.isValid()
Accounts-->>DAccountsManager: error reply
DAccountsManager-->>UserModel: DUnexpected reply error
else valid reply
Accounts-->>DAccountsManager: QList<QDBusObjectPath>
DAccountsManager->>DAccountsManager: getUIDFromObjectPath(user.path())
DAccountsManager-->>UserModel: QList<quint64>
end
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Member
Author
|
Closed in favor of linuxdeepin/dtksystemsettings#148 — dtk6 will auto-sync from main repo. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
DAccountsManager::userList()在org.freedesktop.Accounts不可用时直接解引用空QArrayDataPointer<QDBusObjectPath>(needsDetach(this=0x0)),导致SIGSEGV(exit 139)。gdb栈:在
treeland启动时必现:Helper::init无条件实例化UserModelQML 单例,dde-system-daemon(org.deepin.dde.Accounts1)因 Goconcurrent map竞态崩溃后,org.freedesktop.Accounts虽在但QDBusPendingReply::value()的解包路径在部分传输下返回QDBusArgument而非QList<QDBusObjectPath>,原有!isValid检查不足,遍历空指针列表触发崩溃。treeland侧虽已加isServiceRegistered防护(ca5936d),库侧仍需健壮。Fix
QDBusConnection::systemBus().interface()->isServiceRegistered("org.freedesktop.Accounts"),不可用时直接返回DUnexpected{ServiceUnknown},避免发 DBuswaitForFinished后同时检查isError() || !isValid()const auto value = reply.value()拷贝后遍历,跳过空path(),避免解包失败时的空QList解引用已在
archlinux+accounts-daemon 788+treelandbuild/src/treeland验证:原库./build/src/treeland必SIGSEGV,补丁库LD_LIBRARY_PATH=/tmp/dtk_build/src后正常启动至锁屏/多任务视图,无崩溃。Test
./tmp/test3直接调用DAccountsManager::userList()返回 4 用户正常treeland原分支 + 补丁库:timeout 4 treeland从EXIT:139变为EXIT:124(wayland-0.lock正常退出),无SIGSEGVcmake --build /tmp/dtk_build通过Log: fix accounts userList SIGSEGV when service unavailable
Summary by Sourcery
Harden account user listing against unavailable services and malformed D-Bus responses.
Bug Fixes:
Enhancements: