Repository navigation
Close original standard descriptors and keep C++ streams attached - #579
Open
perfloop-agent wants to merge 1 commit into
Open
perfloop-agent wants to merge 1 commit into
perfloop-agent wants to merge 1 commit into
Conversation
Signed-off-by: Perfloop Agent <agent@perfloop.ai> Signed-off-by: Tomás Senart <ts@perfloop.ai>
perfloop
Bot
force-pushed
the
perfloop-pr-open-msy2k2kavp
branch
from
November 1, 2026 13:40
3cb5fb0 to
2a70743
Compare
Contributor
|
@perfloop-agent The actual fix is a bit more involved. We need to create a new Stream type to hold state. For example, streams must remember the floating point formatting, string padding, etc. |
This branch has not been deployed
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
Closing a standard descriptor in refcount output now releases the OS descriptor with that number, so open can reuse it. C++ standard streams follow the original descriptor and return I/O errors after close instead of panicking or writing to a duplicate.
Generated refcount code remains safe Rust. The registry stays thread-local and intentionally keeps its existing
ub: bad fdpanic policy for unregistered numbers, rather than native C'sEBADF. This includes main's first close after another thread closes that standard descriptor if main's registry is still uninitialized; it is not cross-thread ownership tracking.C++ streams still do not model sticky error flags; insertion expressions discard returned I/O errors. Application exposure and runtime performance remain unmeasured.
Testing
8 recorded checks pass with this change.
The scoped lit selection covers 42 refcount/unsafe cases. tests/unit/fd_close_standard.c compares close/open/read and descriptor-number reuse with native C. The unsafe model's descriptor-close behavior is unchanged.
tests/unit/iostream_closed.cpp compares close(1), cout, then cerr with native C++, followed by a write to closed stderr. tests/unit/stdcopy_ostream.cpp checks owned file-stream output by reading it back. The runtime's
file_stream_iotest checks binary reads, writes and cloned-file lifetime.The macOS
unit/max.cpp/refcountcheck remains owned by target CI. Its generated-output mismatch is also present in the unchanged base's CI run.Case and evidence
Generated by Perfloop. Human sponsor: Tomás Senart.