Skip to content

Commit

Permalink
[corlib] Ensure that Console Streams are thread-safe
Browse files Browse the repository at this point in the history
The Console class wraps the standard system stream reader/writers on construction so as to expose them as thread-safe. However, the Set-Out/In/Err methods in referencesource do not do the same when they replace default targets.

CoreFX code does: https://github.com/mono/corefx/blob/1748f6492e8b96842f76e1a9e7b5d7e8ccfca480/src/System.Console/src/System/Console.cs\#L412-L444

Possible fix for #11146
  • Loading branch information
alexischr authored and marek-safar committed Oct 18, 2018
1 parent a9b1acb commit ec1a736
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mcs/class/corlib/System/Console.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public static void SetError (TextWriter newError)
if (newError == null)
throw new ArgumentNullException ("newError");

stderr = newError;
stderr = TextWriter.Synchronized (newError);
}

[SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
Expand All @@ -252,7 +252,7 @@ public static void SetIn (TextReader newIn)
if (newIn == null)
throw new ArgumentNullException ("newIn");

stdin = newIn;
stdin = TextReader.Synchronized (newIn);
}

[SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
Expand All @@ -261,7 +261,7 @@ public static void SetOut (TextWriter newOut)
if (newOut == null)
throw new ArgumentNullException ("newOut");

stdout = newOut;
stdout = TextWriter.Synchronized (newOut);
}

public static void Write (bool value)
Expand Down

0 comments on commit ec1a736

Please sign in to comment.