Another point is that for any asynchronous appender implementation, it's a sine 
qua non that the LoggingEvent class be thread-safe.

At least for the manipulations an appender might do: layout, accessing 
properties, fixing properties.

I had a quick browse through the source and found what looks to me like a race 
condition here:

             public object LookupProperty(string key)
             {
                    if (m_data.Properties != null)
                    {
                           return m_data.Properties[key];
                    }
                    if (m_compositeProperties == null)
                    {
                           CreateCompositeProperties();
                    }
                    return m_compositeProperties[key];
             }

             private void CreateCompositeProperties()
             {
                    m_compositeProperties = new CompositeProperties();

                    if (m_eventProperties != null)
                    {
                           m_compositeProperties.Add(m_eventProperties);
                    }
                    ... etc

If two threads call LookupProperty concurrently, one may start executing 
CreateCompositeProperties and the other might access m_compositeProperties 
before it's fully created.
If I'm right, the fix is simple - don't set m_compositeProperties until it's 
completely created.


Reply via email to