Repository navigation
fix: 关闭泄漏检测避免UT被误判失败 - #551
Merged
Merged
Conversation
1. Qt/QApplication one-shot allocations are never freed at exit 2. LeakSanitizer then kills the test process with exit code 1 even though all gtest cases passed 3. The ASan report is redirected to asan.log.* by __sanitizer_set_report_path, so nothing shows in the UT console 4. Export ASAN_OPTIONS=detect_leaks=0 in test-prj-running.sh so the exit code reflects real test results Log: No user-facing changes Influence: 1. Run tests/test-prj-running.sh on the UT cluster and check the job exits with code 0 while all cases pass 2. Run deepin-log-viewer-test and deepin-log-viewer-plugin-test manually and verify the PASSED counts match ut-summary.json 3. Confirm no asan.log.* files are generated and the coverage report is still produced normally fix: 关闭泄漏检测避免UT被误判失败 1. Qt/QApplication退出时的一次性分配不会被释放 2. LeakSanitizer会以退出码1结束测试进程,即使全部用例已通过 3. ASan报告被__sanitizer_set_report_path重定向到asan.log.*, 控制台日志中完全不可见 4. 在test-prj-running.sh中导出ASAN_OPTIONS=detect_leaks=0, 使退出码真实反映测试结果 Log: 无用户可见变化 Influence: 1. 在UT集群执行tests/test-prj-running.sh,确认任务退出码为0 且全部用例通过 2. 手动执行deepin-log-viewer-test与deepin-log-viewer-plugin-test, 核对PASSED数量与ut-summary.json一致 3. 确认不再生成asan.log.*文件,且覆盖率报告仍正常产出
|
Warning
详情 {
"export": {
"tests/test-prj-running.sh": {
"b": [
"export ASAN_OPTIONS=detect_leaks=0"
]
}
}
} |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe test runner now disables LeakSanitizer leak detection before running the two unit-test binaries, ensuring the final exit code reflects gtest failures rather than unavoidable Qt/third-party framework leaks hidden in redirected sanitizer logs. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
lzwind
approved these changes
Oct 24, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, pengfeixx 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 |
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.
问题现象
UT 集群上执行
tests/test-prj-running.sh,690 个测试用例(682 + 8)全部 PASSED、覆盖率报告也正常生成,但任务最终以exit_code=1被判失败,日志中找不到任何[ FAILED ]或 AddressSanitizer 报错。原因分析
-fsanitize=undefined,address(CMAKE_SAFETYTEST_ARG_ON),进程退出时 LeakSanitizer 检测到内存泄漏后以退出码 1 结束进程;QColormap::initialize、QApplicationPrivate::initialize等)以及第三方库 libxlsxwriter/DocxFactory,属于无法避免的框架级"良性"泄漏;tests/src/ut_main.cpp中__sanitizer_set_report_path("asan.log")会把 sanitizer 报告重定向到asan.log.<pid>文件,导致控制台日志完全看不到泄漏报告,表现为"全部通过却失败";exit $test_exit_code(两个测试进程退出码取或),整体任务被判失败。已在本地完整复现:两个测试进程均为"全部 PASSED + 退出码 1",
asan.log.*中内容为LeakSanitizer: detected memory leaks(170892 字节 / 1483 处,绝大部分来自 Qt 与第三方库)。修改内容
在
tests/test-prj-running.sh运行测试前导出ASAN_OPTIONS=detect_leaks=0,关闭退出时的泄漏检测,使进程退出码真实反映 gtest 结果。已验证:关闭后两个测试进程退出码均为 0,用例全部通过。自测说明
CMAKE_SAFETYTEST_ARG_ON)构建并运行deepin-log-viewer-test(682 个)与deepin-log-viewer-plugin-test(8 个),全部通过,退出码 0bash -n语法检查通过Summary by Sourcery
Bug Fixes: