Skip to content

[Engine] serve: a failed engine start no longer crashes when another thread closed the process - #4792

Open
sdroege wants to merge 1 commit into
Niko1221:mainfrom
sdroege:fix-serve-restart
Open

sdroege wants to merge 1 commit into
Niko1221:mainfrom
sdroege:fix-serve-restart

Conversation

@sdroege

@sdroege sdroege commented Oct 31, 2026 •

Copy link
Copy Markdown

Problem and result

After an engine abort, StrataEngine.restart() calls __init__() again. If another thread had already called close() and set self.proc to None, the failed-start cleanup dereferenced it:

File "serve/server.py", line 1334, in restart
  self.__init__(*self.spawn)
File "serve/server.py", line 1106, in __init__
  self.proc.stdin.close()
AttributeError: 'NoneType' object has no attribute 'stdin'

A recoverable engine abort (exit -6 after a GPU hang) became a 400 and a stopped server. After the fix the same abort restarts the engine normally.

Related discussion

none

Approach

Keep the spawned process in a local (proc = self.proc) and use it in the failed-start cleanup, with None guards. If another thread has already closed the process, the cleanup is skipped. No behaviour change otherwise.

Validation

Passed:

  • Reproduced on a Radeon AI PRO R9700 (gfx1201), engine 0.1.54, with a GPU hang (engine exit -6); the traceback above is from that run.
  • After the fix, the same hang sequence restarts the engine normally (three aborts in one benchmark run, each followed by a restart).
  • python -m py_compile serve/server.py passes.

Failed:

  • none observed

Not run:

  • The full test suite. Only the server was exercised on the one machine.

Limits

This only prevents the AttributeError; it does not change the engine's behaviour or the GPU hang itself.

@github-actions github-actions Bot added the needs-format Title or template does not follow CONTRIBUTING.md yet label Oct 31, 2026
@github-actions

Copy link
Copy Markdown

Thanks for the pull request. To keep the tracker readable, every item needs an area prefix in the title and the parts of the pull request template filled in. This one is missing:

  • Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other], then a short description. Example: "[Engine] fix decode stop on long prompts".

Edit the pull request (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment /reopen.

Details: CONTRIBUTING.md

@sdroege sdroege changed the title serve: a failed engine start no longer crashes when another thread closed the process [Engine] serve: a failed engine start no longer crashes when another thread closed the process Oct 31, 2026
@github-actions github-actions Bot removed the needs-format Title or template does not follow CONTRIBUTING.md yet label Oct 31, 2026
@github-actions

Copy link
Copy Markdown

Thanks, this follows the format now.

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.

1 participant