Repository navigation
Fix issue when logging stack overflow in WinForm apps. - #114432
Merged
lateralusX merged 3 commits intoApr 11, 2025
Merged
lateralusX merged 3 commits into
lateralusX merged 3 commits into
Conversation
am11
reviewed
Apr 9, 2025
Member
jkotas
reviewed
Apr 9, 2025
jkotas
approved these changes
Apr 9, 2025
AaronRobinsonMSFT
approved these changes
Apr 9, 2025
|
@lateralusX - is this specific to StackOverflow? I see VS debugger hangs on Binder exceptions as well |
Member
Author
It will happen to anything that logs through this function, there are some low level errors and low level exceptions that could take that route, so likely related. |
WinForm apps doesn't have a console and apparently, Windows implementation of fileno doesn't have same behaviour as POSIX implementation where a return of -1 means error. On Windows, fileno will return -2 when there is no console attached to the app. This bypass the check in write_file that should have return 0, instead it will call_write that will return an error that was not fully accounted for leading to a infinite loop. Fix makes sure Windows implementation sees -1 and -2 as invalid file descriptors. Fix also account for errors returned by _write breaking out of the loop. Fixes dotnet#114412.
is no real error return, so as long as it gets called with a valid stream, it should return something that write/_write should handle and since we handle error returns from calls to write/_write, in minipal_log_write it might be better to let underlying API's decode the meaning of file descriptors returned by fileno/_fileno. minipal_log_write will only pass stdout/stderr to fileno/_fileno and they should always be valid file streams, even if there is no console attached. On a Windows app running without console, it will return back a file descriptor of -2 in that case that _write will see as a unavailable console and return -1 that minipal_log_write will handle.
lateralusX
force-pushed
the
lateralusX/fix-stack-overflow-winform-issue
branch
from
April 10, 2025 07:47
bdbe453 to
9ea343f
Compare
This was referenced Apr 10, 2025
Open
Member
Author
|
Failures are known errors. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
WinForm apps doesn't have a console and apparently, Windows implementation of
filenodoesn't have same behavior as POSIX implementation where a return of -1 means error. On Windows,filenowill return -2 when there is no console attached to the app. This bypass the check inwrite_filethat should have return 0, instead it will call_writethat will return an error that was not fully accounted for leading to an infinite loop.Fix makes sure Windows implementation sees -1 and -2 as invalid file descriptors. Fix also account for errors returned by
_writebreaking out of the loop.Fixes #114412.