Avoid a Buildbot bug that can hang CTest steps forever - #371
Merged
Conversation
CTest.run() fetches the ctest XML results file from the worker via getFileContentFromWorker(), which uses buildbot's StringFileWriter. That class decodes each 32KB transfer chunk as UTF-8 independently (buildbot/process/remotetransfer.py), so a multi-byte character split across a chunk boundary raises UnicodeDecodeError inside a PB remote-message handler rather than through buildbot's normal command-failure path. The step is never notified, so it hangs forever, still holding its counting-mode claim on performance_lock -- which then starves any sibling step on the same worker that needs exclusive access to that lock (e.g. the performance test steps), for however long it takes someone to notice and restart the master. This is a long-standing, still-open upstream bug (buildbot/buildbot#3982); a 2019 fix attempt (buildbot/buildbot#4621) stalled in review and was closed by stale-bot without landing, and it's still present in the pinned 4.3.0 release, so there's no version bump that avoids it. Since Xml.fromstring() accepts bytes directly, we don't need decoded text here at all: read the file as raw bytes via a small custom FileWriterImpl instead of buildbot's decoding one, sidestepping the bug rather than working around its symptoms. Confirmed against a byte-for-byte reproduction of the production failure (same "position 32767: unexpected end of data" error) that the old writer raises and the new one doesn't. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
performance_lockforever on that worker, starving any sibling step needing exclusive access (e.g. performance tests). This happened even when the superseding-commit cancellation service tried to cancel the offending build -- there was nothing left to cancel, because the step wasn't running a command or waiting on a lock; it was permanently parked inside a hung file transfer.CTest.run()fetches the CTest XML results file from the worker viagetFileContentFromWorker(), which uses buildbot'sStringFileWriter. That class decodes each 32KB transfer chunk as UTF-8 independently (buildbot/process/remotetransfer.py), so a multi-byte character split across a chunk boundary raisesUnicodeDecodeErrorinside a Twisted PB remote-message handler -- not through buildbot's normal command-failure path -- so the step is never notified and hangs forever.buildbot~=4.0(currently resolving to 4.3.0), so there's no version bump that avoids it.Xml.fromstring()acceptsbytesdirectly, we don't need decoded text at all here. Added a small_BytesFileWriter(aFileWriterImplthat keeps raw bytes) and a localgetFileBytesFromWorker()incustom_steps.py, sidestepping the bug entirely instead of working around its symptoms.Test plan
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe2 in position 32767: unexpected end of data) standalone by feeding a chunk-boundary-split multi-byte character through buildbot's realStringFileWriter, and confirmed the new_BytesFileWriterparses the same input cleanly viaXml.fromstring.uv run ruff check/ruff format --checkonmaster/custom_steps.pyuv run ty check master/custom_steps.pybuildbot checkconfig .🤖 Generated with Claude Code