Severity: Info
File: src/Servy.Core/Logging/Logger.cs, line 94
Description:
InternalInitialize disposes the old _writer and creates a new one. If another thread is mid-Log() and has passed the if (_writer == null) return; check (line 285) but not yet entered the lock, it will try to write to the disposed writer.
The double-check at line 293 re-checks inside the lock, which prevents most races, but the outer null-check at line 285 is a stale read that could cache a non-null _writer reference that was just disposed.
Suggested fix:
Use a volatile read for _writer at line 285, or replace the double-check with a full lock acquisition. Alternatively, drain in-flight writes before disposing.
Severity: Info
File:
src/Servy.Core/Logging/Logger.cs, line 94Description:
InternalInitializedisposes the old_writerand creates a new one. If another thread is mid-Log()and has passed theif (_writer == null) return;check (line 285) but not yet entered the lock, it will try to write to the disposed writer.The double-check at line 293 re-checks inside the lock, which prevents most races, but the outer null-check at line 285 is a stale read that could cache a non-null
_writerreference that was just disposed.Suggested fix:
Use a
volatileread for_writerat line 285, or replace the double-check with a full lock acquisition. Alternatively, drain in-flight writes before disposing.