Repository navigation
fix: destroy DOcr engine on quit to avoid SIGSEGV - #289
deepin-bot[bot] merged 1 commit into
Conversation
1. Root cause: sharedOcrEngine() creates a DOcr singleton that is never destroyed; on process exit DOcr's internal worker threads still have posted events targeting deleted QObjects, causing SIGSEGV in sendPostedEvents 2. Fix: connect to QCoreApplication::aboutToQuit to delete the DOcr engine before process exit, ensuring internal worker threads are stopped and event queues drained 3. Impact: only affects process exit path, no change to normal OCR extraction functionality Log: Fixed SIGSEGV crash on extractor process exit Influence: 1. Test extractor exit on idle timeout, verify no SIGSEGV 2. Test extractor exit on stdin close, verify no SIGSEGV 3. Verify normal OCR image extraction still works correctly fix: 退出时销毁DOcr引擎避免段错误 1. 根因:sharedOcrEngine()创建的DOcr单例永不销毁,进程退出时 DOcr内部工作线程事件队列中残留已投递事件,其接收者QObject已 被销毁,sendPostedEvents派发到悬垂指针导致SIGSEGV 2. 方案:连接QCoreApplication::aboutToQuit信号,在进程退出前 销毁DOcr引擎,确保内部工作线程正确停止并清空事件队列 3. 影响:仅影响进程退出路径,不影响正常OCR提取功能 Log: 修复extractor进程退出时的段错误崩溃 Influence: 1. 测试extractor空闲超时退出,确认无段错误 2. 测试extractor stdin关闭退出,确认无段错误 3. 验证正常OCR图片提取功能不受影响
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Johnson-zs 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 GuideThe PR fixes extractor shutdown crashes by registering the lazily created shared DOcr engine for deletion when QCoreApplication emits aboutToQuit, preventing worker-thread events from targeting destroyed QObjects while leaving normal OCR extraction behavior unchanged. Sequence diagram for safe OCR engine shutdownsequenceDiagram
participant Extractor
participant QCoreApplication
participant DOcr
participant WorkerThreads
Extractor->>DOcr: sharedOcrEngine()
DOcr-->>Extractor: return engine
Extractor->>QCoreApplication: connect(aboutToQuit, delete engine)
QCoreApplication-->>QCoreApplication: aboutToQuit
QCoreApplication->>DOcr: delete engine
DOcr->>WorkerThreads: stop internal worker threads
DOcr->>WorkerThreads: drain posted event queues
WorkerThreads-->>QCoreApplication: shutdown safely
Flow diagram for extractor exit crash preventionflowchart TD
A[Extractor begins shutdown] --> B[QCoreApplication emits aboutToQuit]
B --> C[Delete shared DOcr engine]
C --> D[Stop worker threads and drain event queues]
D --> E[Process exits without SIGSEGV]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: ['当前实现已能正确解决 SIGSEGV 问题,无需额外修改。'] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: ['建议保持当前注释风格,便于后续维护者理解退出时销毁引擎的必要性。'] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: ['无需性能优化。'] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: ['无需安全加固。'] 💡 改进建议代码示例// 当前实现已为正确修复方式,无需改动。完整示例: // // #include <QCoreApplication> // // Dtk::Ocr::DOcr *sharedOcrEngine() // { // static Dtk::Ocr::DOcr *engine = []() { // auto *e = new Dtk::Ocr::DOcr(); // if (!e->loadEngine()) { // delete e; // return nullptr; // } // QObject::connect(qApp, &QCoreApplication::aboutToQuit, qApp, [e]() { // delete e; // }); // return e; // }(); // return engine; // }本报告由 AI 代码审查工具自动生成 |
|
/forcemerge |
fix: destroy DOcr engine on quit to avoid SIGSEGV
never destroyed; on process exit DOcr's internal worker threads
still have posted events targeting deleted QObjects, causing
SIGSEGV in sendPostedEvents
engine before process exit, ensuring internal worker threads are
stopped and event queues drained
extraction functionality
Log: Fixed SIGSEGV crash on extractor process exit
Influence:
fix: 退出时销毁DOcr引擎避免段错误
DOcr内部工作线程事件队列中残留已投递事件,其接收者QObject已
被销毁,sendPostedEvents派发到悬垂指针导致SIGSEGV
销毁DOcr引擎,确保内部工作线程正确停止并清空事件队列
Log: 修复extractor进程退出时的段错误崩溃
Influence:
Summary by Sourcery
Bug Fixes: