bugfix: clean NPU process shutdown (bypass process-static destructors). - #2209
Open
Enguikong wants to merge 1 commit into
Open
bugfix: clean NPU process shutdown (bypass process-static destructors).#2209Enguikong wants to merge 1 commit into
Enguikong wants to merge 1 commit into
Conversation
SIGTERM shutdown triggers Ascend libopp_registry process-static destructors plus a pybind GIL dec_ref that raise terminate after run() cleanup. std::_Exit skips static destructors for a clean exit. Orthogonal to DCP; submitted separately. Co-Authored-By: Claude <noreply@anthropic.com>
Enguikong
requested review from
DongheJin,
DragonFive,
JimHsiung,
Kang-Meng,
liujinguang0125,
liutongxuan,
ustcfy,
xiao-yu-chen,
yingxudeng,
yinjiawei01 and
zhang-minchao
as code owners
August 12, 2026 09:24
Contributor
There was a problem hiding this comment.
Pull request overview
This PR changes the NPU build’s process-exit behavior to avoid crashes during shutdown caused by process-static destructors (notably Ascend libopp_registry.so) interacting poorly with pybind/Python teardown. It introduces an explicit NPU exit path that flushes logs/stdio and then terminates via std::_Exit(...) to bypass static destructors.
Changes:
- Add
exit_npu_process(int)that shuts down verbose tracing, flushes glog and stdio streams, then callsstd::_Exit(exit_code). - Update
main()to callexit_npu_process(run())underUSE_NPUinstead of returning frommain.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
问题
SIGTERM 停服时,Ascend
libopp_registry.so的进程静态析构 + pybind GILdec_ref会在run()清理之后抛terminate,导致进程非干净退出(core/terminate)。方案
新增
exit_npu_process(int):flush 日志/stdio 后调用std::_Exit,跳过进程静态析构,干净退出。main()在USE_NPU下用它替代return run()。说明
🤖 Generated with Claude Code