fix: ddialog's lambda func may cause segfault - #620
Merged
Conversation
deepin-ci-robot
added a commit
to linuxdeepin/dtk6widget
that referenced
this pull request
Nov 21, 2024
Synchronize source files from linuxdeepin/dtkwidget. Source-pull-request: linuxdeepin/dtkwidget#620
deepin-ci-robot
added a commit
to linuxdeepin/dtk6widget
that referenced
this pull request
Nov 22, 2024
Synchronize source files from linuxdeepin/dtkwidget. Source-pull-request: linuxdeepin/dtkwidget#620
kegechen
reviewed
Nov 22, 2024
During call DDialog::exec(), the onButtonClickedClose flag is set to true by default. At this point, DDialog connect lambda function captures the **temporary variable**, and does not disconnect the signal after the exec() call ends. As a result of calling the same dialog object multiple times, other addresses may be **overwritten** by previous temporary variable writes, causing segfault (crashes). Use done() to set the return value instead of via connect lambda function. Log: Fixed a bug that may cause segfault.
deepin-ci-robot
added a commit
to linuxdeepin/dtk6widget
that referenced
this pull request
Nov 22, 2024
Synchronize source files from linuxdeepin/dtkwidget. Source-pull-request: linuxdeepin/dtkwidget#620
Contributor
|
TAG Bot New tag: 5.7.3 |
kegechen
approved these changes
Nov 22, 2024
Contributor
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: kegechen, rb-union 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 |
Contributor
Author
|
/forcemerge |
Contributor
|
This pr force merged! (status: behind) |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
DDialog 的 onButtonClickedClose 标记默认是 true.
exec() 下绑定的 lambda 函数在 exec() 调用后没有断开连接,复用对话框,调用 exec() 会连接多个 lambda 槽函数。
而这个lambda函数捕获临时变量,这个临时地址可能和后续其它的变量地址重合,变量被覆写后再访问可能触发段错误。
尝试直接用done()传入resultCode,就不用关联信号了。
请审核下没考虑的问题或更优方案。