Skip to content

Conversation

@wangrong1069
Copy link
Contributor

@wangrong1069 wangrong1069 commented Oct 23, 2025

The direct cause of the program crash is that a pure virtual function is called in the destructor of the base class. Let's move the cleanup from ~base_event_handler() into terminate_processing().

Summary by Sourcery

Bug Fixes:

  • Prevent core dump by relocating task and job cleanup out of the destructor into terminate_processing

The direct cause of the program crash is that a pure virtual function
is called in the destructor of the base class. Let's move the cleanup
from ~base_event_handler() into terminate_processing().
@github-actions
Copy link

TAG Bot

TAG: 7.0.31
EXISTED: no
DISTRIBUTION: unstable

@sourcery-ai
Copy link

sourcery-ai bot commented Oct 23, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This patch prevents a pure virtual function call in the base class destructor by relocating the pending-task wait and job‐cleanup logic from ~base_event_handler() into terminate_processing().

Class diagram for updated base_event_handler cleanup logic

classDiagram
class base_event_handler {
    +terminate_processing()
    -pool_: ThreadPool
    -jobs_: std::vector<Job>
    -eat_job(Job)
    ~base_event_handler()  // destructor no longer performs job cleanup
}

base_event_handler : terminate_processing() now performs job cleanup
base_event_handler : ~base_event_handler() no longer calls eat_job()
Loading

File-Level Changes

Change Details Files
Relocate cleanup from destructor to terminate_processing to prevent pure virtual call
  • Removed pool_.wait_for_tasks() from base_event_handler destructor
  • Removed jobs_ cleanup loop from base_event_handler destructor
  • Inserted pool_.wait_for_tasks() into terminate_processing()
  • Inserted jobs_ cleanup loop into terminate_processing()
src/daemon/src/core/base_event_handler.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot
Copy link

deepin pr auto review

我来对这个diff进行审查:

  1. 代码变更分析:
    这个修改主要是将base_event_handler析构函数中的清理代码移动到了terminate_processing()函数中。这是一个很好的改动,因为它解决了可能存在的coredump问题。

  2. 改进意见:

语法逻辑:

  • 代码变更在语法上是正确的,没有明显的语法错误。
  • 逻辑上更加合理,因为terminate_processing()是专门用于终止处理的函数,将清理工作放在这里更合适。

代码质量:

  • 这个改动提高了代码的可维护性,因为相关的终止和清理操作现在集中在一个地方。
  • 代码注释清晰,说明了"Eat all jobs"的目的。

代码性能:

  • 性能方面没有显著变化,因为只是代码位置的移动,没有改变实际的执行逻辑。

代码安全:

  • 这个改动提高了代码的安全性,避免了在析构函数中进行复杂操作可能导致的崩溃问题。
  • 将清理工作从析构函数移到terminate_processing()可以避免在对象销毁时出现未定义行为。
  1. 具体建议:
  • 建议在terminate_processing()函数开始处添加日志,记录开始执行清理操作,这样有助于调试。
  • 考虑添加错误处理机制,在清理jobs_时捕获可能的异常。
  • 可以考虑在move job之前检查job的有效性。
  1. 其他建议:
  • changelog中的版本号7.0.31应该遵循语义化版本控制规范。
  • changelog中的日期2025年看起来可能是笔误,应该使用当前年份。

总体来说,这是一个很好的改进,修复了coredump问题,提高了代码的健壮性和可维护性。建议可以采纳这个改动。

@lzwind lzwind merged commit d01cbfa into linuxdeepin:develop/snipe Oct 23, 2025
19 checks passed
@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: lzwind, wangrong1069

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@wangrong1069 wangrong1069 deleted the pr1023 branch October 23, 2025 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants