Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix non-thread safe Flush() in RedirectConsoleWriter #10013

Open
YuliiaKovalova opened this issue Apr 16, 2024 · 3 comments
Open

Fix non-thread safe Flush() in RedirectConsoleWriter #10013

YuliiaKovalova opened this issue Apr 16, 2024 · 3 comments
Labels
backlog Priority:2 Work that is important, but not critical for the release triaged

Comments

@YuliiaKovalova
Copy link
Member

YuliiaKovalova commented Apr 16, 2024

[pre-existing] It looks like the goal of this class is to expose a thread-safe StringWriter but this method is not thread-safe. Writes that happen between these two statements may be lost or corrupt the StringBuilder.

Originally posted by @ladipro in #9983 (comment)

@AR-May
Copy link
Member

AR-May commented Apr 16, 2024

team triage: @YuliiaKovalova what is your suggested priority for it?

@YuliiaKovalova YuliiaKovalova added the Priority:2 Work that is important, but not critical for the release label Apr 16, 2024
@YuliiaKovalova
Copy link
Member Author

cc: @rokonec MSBuild Server-related topic

@rokonec
Copy link
Contributor

rokonec commented Apr 19, 2024

Purpose of this class was to redirect all console writes from msbuild server to its client (invoker).
Since msbuild access console in serial fashion, this class was not originally written as thread safe. However, if custom code (tasks, logger and such) do call console flush directly it might interfere with logging service thread. Accessing console directly is not supported and customers shall avoid it. But if I understand it correctly, console is wired with _syncWriter = Synchronized(this); which is supposed to be thread safe wrapper.
I recommend to close this issues as "this is fine".
@MichalPavlik as an author of these particular lines, what is your take?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Priority:2 Work that is important, but not critical for the release triaged
Projects
None yet
Development

No branches or pull requests

3 participants