The problem here is similar to
LOG4NET-212 where an instance variable is modified by concurrent threads.
I'd say ProtectCloseTextWriter's Attach method is evil and TextwriterAdapter's m_writer should be readonly, but that would break too many APIs.
Other than with
LOG4NET-212 I don't intend to keep the instance member and add synchronization but will rather remove the instance member completely.
I don't think the stack would really solve the problem, maybe make it surface less often.