Log4net
  1. Log4net
  2. LOG4NET-76

TextWriterAdapter is not thread safe

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2.10
    • Fix Version/s: 1.2.11
    • Component/s: Core
    • Labels:
      None
    • Environment:
      Windows XP Pro sp2 with .Net 2

      Description

      When logging using the XmlAppender, our company application can generate overlapping appender calls. TextWriterAppender is not thread safe.

        Activity

        Hide
        Stefan Bodewig added a comment -

        fixed (really this issue this time, promised with svn revision 1169783

        Show
        Stefan Bodewig added a comment - fixed (really this issue this time, promised with svn revision 1169783
        Hide
        Stefan Bodewig added a comment -

        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.

        Show
        Stefan Bodewig added a comment - 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.
        Hide
        Stefan Bodewig added a comment -

        Closed the wrong bug.

        Show
        Stefan Bodewig added a comment - Closed the wrong bug.
        Hide
        Stefan Bodewig added a comment -

        The immediate multi-threading problem is fixed with svn revsion 1169711

        I'll open a new issue to review whether we actually need ReusableStringWriter at al in a future release.

        Show
        Stefan Bodewig added a comment - The immediate multi-threading problem is fixed with svn revsion 1169711 I'll open a new issue to review whether we actually need ReusableStringWriter at al in a future release.
        Hide
        Ron Grabowski added a comment -

        Can you provide an NUnit test case to confirm this?

        Show
        Ron Grabowski added a comment - Can you provide an NUnit test case to confirm this?
        Hide
        Bob Peterson added a comment -

        Sorry, I meant this bug is triggered through out use of XmlLayout, not some fictional "Xml appender."

        Show
        Bob Peterson added a comment - Sorry, I meant this bug is triggered through out use of XmlLayout, not some fictional "Xml appender."
        Hide
        Bob Peterson added a comment -

        This is a possible fix for the problem, at least for the use case of the Xml formatter. A stack is introduced to cope with the implicit push and pop of writers.

        Show
        Bob Peterson added a comment - This is a possible fix for the problem, at least for the use case of the Xml formatter. A stack is introduced to cope with the implicit push and pop of writers.

          People

          • Assignee:
            Unassigned
            Reporter:
            Bob Peterson
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development