Skip to content

fix(coverage): force DISABLE_HOOK cache var to fix fresh-configure crash#774

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
pengfeixx:fix/coverage-disable-hook-cmp0077
Jul 17, 2026
Merged

fix(coverage): force DISABLE_HOOK cache var to fix fresh-configure crash#774
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
pengfeixx:fix/coverage-disable-hook-cmp0077

Conversation

@pengfeixx

Copy link
Copy Markdown
Contributor

Previous fix set DISABLE_HOOK as a normal variable, but coost's subdirectory has its own cmake_minimum_required(VERSION 3.12), causing CMP0077 to fall back to OLD where option() ignores normal variables and overwrites the cache with OFF on fresh configure.

Coost 子目录自带 cmake_minimum_required(VERSION 3.12), 进入子作用域后 CMP0077 退化为 OLD, option() 会无视父级 normal 变量并覆写 cache, 导致 全新配置时 _CO_DISABLE_HOOK 编译宏缺失, 测试退出阶段 coost hook 触发 SIGSEGV, 覆盖率从 ~80% 跌至 ~32%。改用 set(... CACHE BOOL ... FORCE) 强制写 cache, option() 见到已存在值不再覆盖。

Log: 修复全新配置时 coost hook 未禁用导致覆盖率崩溃
Influence: 全新 clone 后跑 test-prj-running.sh 不再出现测试退出段错误, 覆盖率从 ~32% 恢复至 ~80.6%; 增量构建行为不变。

Previous fix set DISABLE_HOOK as a normal variable, but coost's
subdirectory has its own cmake_minimum_required(VERSION 3.12), causing
CMP0077 to fall back to OLD where option() ignores normal variables
and overwrites the cache with OFF on fresh configure.

Coost 子目录自带 cmake_minimum_required(VERSION 3.12), 进入子作用域后
CMP0077 退化为 OLD, option() 会无视父级 normal 变量并覆写 cache, 导致
全新配置时 _CO_DISABLE_HOOK 编译宏缺失, 测试退出阶段 coost hook 触发
SIGSEGV, 覆盖率从 ~80% 跌至 ~32%。改用 set(... CACHE BOOL ... FORCE)
强制写 cache, option() 见到已存在值不再覆盖。

Log: 修复全新配置时 coost hook 未禁用导致覆盖率崩溃
Influence: 全新 clone 后跑 test-prj-running.sh 不再出现测试退出段错误,
覆盖率从 ~32% 恢复至 ~80.6%; 增量构建行为不变。

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @pengfeixx, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:95分

■ 【总体评价】

代码正确修复了CMake子目录中变量作用域导致编译宏未生效的问题,注释详尽。
逻辑正确,修复方案符合CMake最佳实践,无安全风险,因无扣分项获高分。

■ 【详细分析】

  • 1.语法逻辑(完全正确)✓

修改位于 modules/compat.cmake,将 set(DISABLE_HOOK ON) 修改为 set(DISABLE_HOOK ON CACHE BOOL "disable hooks for system APIs" FORCE)。这正确利用了 CMake 的 CACHE 和 FORCE 机制,解决了由于 CMP0077 策略在子作用域退化为 OLD 时,option() 命令覆盖父级 normal 变量的问题。
潜在问题:无
建议:无

  • 2.代码质量(优秀)✓

代码新增了详细的注释,清晰解释了为什么必须使用 CACHE+FORCE,并指出了相关的 CMake policy (CMP0077) 以及 coost 子目录的行为,极大地提高了代码的可维护性。
潜在问题:无
建议:无

  • 3.代码性能(无性能问题)✓

该改动仅影响 CMake 配置阶段的变量设置,不涉及编译期或运行期的性能开销。
潜在问题:无
建议:无

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
本次修改仅涉及 CMake 构建配置逻辑,未引入任何外部输入处理或敏感操作,不存在安全风险。
建议:无

■ 【改进建议代码示例】

# 当前代码已为最佳实践,无需进一步修改。
if(DOTEST OR BUILD_TESTS)
    set(DISABLE_HOOK ON CACHE BOOL "disable hooks for system APIs" FORCE)
endif()

@deepin-ci-robot

Copy link
Copy Markdown

[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.

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

@pengfeixx

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

This pr force merged! (status: unstable)

@deepin-bot
deepin-bot Bot merged commit c8a13cf into linuxdeepin:master Jul 17, 2026
20 of 22 checks passed
@pengfeixx
pengfeixx deleted the fix/coverage-disable-hook-cmp0077 branch July 17, 2026 07:51
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