Skip to content

bugfix: clean NPU process shutdown (bypass process-static destructors). - #2209

Open
Enguikong wants to merge 1 commit into
xLLM-AI:mainfrom
Enguikong:fix/npu-exit-shutdown
Open

bugfix: clean NPU process shutdown (bypass process-static destructors).#2209
Enguikong wants to merge 1 commit into
xLLM-AI:mainfrom
Enguikong:fix/npu-exit-shutdown

Conversation

@Enguikong

Copy link
Copy Markdown
Contributor

问题

SIGTERM 停服时,Ascend libopp_registry.so 的进程静态析构 + pybind GIL dec_ref 会在 run() 清理之后抛 terminate,导致进程非干净退出(core/terminate)。

方案

新增 exit_npu_process(int):flush 日志/stdio 后调用 std::_Exit,跳过进程静态析构,干净退出。main()USE_NPU 下用它替代 return run()

说明

🤖 Generated with Claude Code

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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 calls std::_Exit(exit_code).
  • Update main() to call exit_npu_process(run()) under USE_NPU instead of returning from main.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@yingxudeng yingxudeng changed the title fix: clean NPU process shutdown (bypass process-static destructors) bugfix: clean NPU process shutdown (bypass process-static destructors) Aug 12, 2026
@yingxudeng yingxudeng changed the title bugfix: clean NPU process shutdown (bypass process-static destructors) bugfix: clean NPU process shutdown (bypass process-static destructors). Aug 12, 2026
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.

2 participants