Skip to content

Properly catch exceptions in {i|o}stream - #2033

Merged
Stephan T. Lavavej (StephanTLavavej) merged 16 commits into
microsoft:mainfrom
miscco:iostream_exceptions
Sep 2, 2021
Merged

Properly catch exceptions in {i|o}stream#2033
Stephan T. Lavavej (StephanTLavavej) merged 16 commits into
microsoft:mainfrom
miscco:iostream_exceptions

Conversation

@miscco

Copy link
Copy Markdown
Contributor

Fixes #1858

Comment thread tests/std/tests/GH_001858_iostream_exception/test.cpp Outdated
@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) added the bug Something isn't working label Jul 2, 2021
Co-authored-by: Igor Zhukov <fsb4000@yandex.ru>
Comment thread stl/inc/istream Outdated
Comment thread stl/inc/istream
Co-authored-by: Adam Bucior <35536269+AdamBucior@users.noreply.github.com>

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.

These are more suggestions than required changes, so I'll go ahead and approve.

Comment thread tests/std/tests/GH_001858_iostream_exception/test.cpp
Comment thread stl/inc/istream
Comment thread stl/inc/istream
Comment thread stl/inc/ostream Outdated
@CaseyCarter Casey Carter (CaseyCarter) removed their assignment Aug 24, 2021
Comment thread stl/inc/istream
Comment thread stl/inc/istream Outdated
Comment thread tests/std/tests/GH_001858_iostream_exception/test.cpp
Comment thread tests/std/tests/GH_001858_iostream_exception/test.cpp Outdated
Comment thread tests/std/tests/GH_001858_iostream_exception/test.cpp Outdated
Comment thread tests/std/tests/GH_001858_iostream_exception/test.cpp
Comment thread tests/std/tests/GH_001858_iostream_exception/test.cpp Outdated
Comment thread tests/std/tests/GH_001858_iostream_exception/test.cpp Outdated
@miscco

Copy link
Copy Markdown
Contributor Author

From my point of view the current iostream situation is a bit broken. We do a lot of gymnastics to not call setstate inside a catch block when it does not really bring any benefit due to the _Reraise = true case that we trigger when the catch block triggers.

I think we could even get around the double exception it if we would simply call setstate(..., true) in those cases, as that would immediately just throw rather than creating an exception that is then eaten by the _CATCH_IO_END

That said, I would definitely not touch this in this PR

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good, I'll go ahead and push changes for one last round of feedback.

Comment thread tests/std/tests/GH_001858_iostream_exception/test.cpp Outdated
Comment thread tests/std/tests/GH_001858_iostream_exception/test.cpp
Comment thread tests/std/tests/GH_001858_iostream_exception/test.cpp Outdated
@StephanTLavavej

This comment has been minimized.

@StephanTLavavej

Copy link
Copy Markdown
Member

I'm mirroring this to an MSVC-internal PR - please notify me if any further changes are pushed.

@StephanTLavavej
Stephan T. Lavavej (StephanTLavavej) merged commit 671daf4 into microsoft:main Sep 2, 2021
@StephanTLavavej

Copy link
Copy Markdown
Member

Thanks for fixing these EH bugs! 🐞 πŸ¦‹ πŸŽ‰

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

<istream>/<ostream> : seekg() and seekp() must catch and rethrow internal io exceptions

5 participants