Skip to content

Flush Python stream item markers before unchecked writes#290

Closed
KairosOps wants to merge 1 commit into
microsoft:mainfrom
KairosOps:fix/python-stream-marker-flush
Closed

Flush Python stream item markers before unchecked writes#290
KairosOps wants to merge 1 commit into
microsoft:mainfrom
KairosOps:fix/python-stream-marker-flush

Conversation

@KairosOps

Copy link
Copy Markdown

Fixes #289.

The per-item streaming path in the Python binary runtime writes the stream item marker with write_byte_no_check(1). When an element lands exactly at the end of the output buffer, the next marker writes past the bytearray before any element serializer gets a chance to flush.

This gives the marker the same one-byte capacity guarantee used by the nearby tag writers. I added a small regression test that uses a 2-byte buffer and optional values so the boundary is hit deterministically.

Checked locally:

  • python -m pytest python\tests\test_binary_stream_writer.py -q
  • python -m py_compile tooling\internal\python\static_files\_binary.py python\tests\test_binary_stream_writer.py
  • git diff --cached --check

@naegelejd

Copy link
Copy Markdown
Contributor

Closed in favor of #292, which fixes the deeper issue and adds missing Coded Stream tests.

@naegelejd naegelejd closed this Jun 25, 2026
@KairosOps

Copy link
Copy Markdown
Author

Sounds good, thanks for closing the loop. I’ll leave this closed in favor of #292.

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.

Python binary stream writer buffer overflow

2 participants