<div dir="ltr"><div>This code from raw_ostream.h is really racy:</div><div><br></div><div>  raw_ostream &operator<<(StringRef Str) {</div><div>    // Inline fast path, particularly for strings with a known length.</div><div>    size_t Size = Str.size();</div><div><br></div><div>    // Make sure we can use the fast path.</div><div>    if (Size > (size_t)(OutBufEnd - OutBufCur))</div><div>      return write(Str.data(), Size);</div><div><br></div><div>    if (Size) {</div><div>      memcpy(OutBufCur, Str.data(), Size);</div><div>      OutBufCur += Size;</div><div>    }</div><div>    return *this;</div><div>  }</div><div><br></div><div><br></div><div>Of course, one might wonder why someone would need to output to a stream from multiple threads at the same time.</div><div><br></div><div>But imagine someone might get logs to dbgs() or errs() running the backend for a target in multiple threads.</div><div>Is there any known practice to avoid such a problem?<br></div></div>