title: Missing stack frames
body: <p>While trying to debug error I faced strange issue with missing stack frames.</p>
  
  <p>Here is excerpt from my log file:</p>
  
  <pre><code>2015-12-18 00:00:01,378 WARN  NHibernate.Util.ADOExceptionReporter (null) - System.IndexOutOfRangeException: Probable I/O race condition detected while copying memory. The I/O package is not thread safe by default. In multithreaded applications, a stream must be accessed in a thread-safe way, such as a thread-safe wrapper returned by TextReader's or TextWriter's Synchronized methods. This also applies to classes like StreamWriter and StreamReader.
     at System.Buffer.InternalBlockCopy(Array src, Int32 srcOffsetBytes, Array dst, Int32 dstOffsetBytes, Int32 byteCount)
     at System.IO.StreamWriter.Write(Char[] buffer, Int32 index, Int32 count)
     at System.IO.TextWriter.WriteLine(String value)
     at System.IO.TextWriter.SyncTextWriter.WriteLine(String value)
     &lt;&lt; HERE LOG4NET STACK FRAMES SHOULD BE&gt;&gt;
     at NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)
     at NHibernate.Loader.Loader.GetResultSet(IDbCommand st, Boolean autoDiscoverTypes, Boolean callable, RowSelection selection, ISessionImplementor session)
     at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies, IResultTransformer forcedResultTransformer)
     at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies, IResultTransformer forcedResultTransformer)
     at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters, IResultTransformer forcedResultTransformer)
  </code></pre>
  
  <p>Regarding by NHibernate.AdoNet.AbstractBatcher.ExecuteReader method directly calling the System.IO.TextWriter.SyncTextWriter.WriteLine method. But there is no such calls:</p>
  
  <pre><code>    public virtual IDataReader ExecuteReader(IDbCommand cmd)
      {
          CheckReaders();
          LogCommand(cmd);
          Prepare(cmd);
          Stopwatch duration = null;
          if (Log.IsDebugEnabled)
              duration = Stopwatch.StartNew();
          IDataReader reader = null;
          try
          {
              reader = cmd.ExecuteReader();
          }
          catch (Exception e)
          {
              e.Data["actual-sql-query"] = cmd.CommandText;
              Log.Error("Could not execute query: " + cmd.CommandText, e);
              throw;
          }
          finally
          {
              if (Log.IsDebugEnabled &amp;&amp; duration != null &amp;&amp; reader != null)
              {
                  Log.DebugFormat("ExecuteReader took {0} ms", duration.ElapsedMilliseconds);
                  _readersDuration[reader] = duration;
              }
          }
  
          if (!_factory.ConnectionProvider.Driver.SupportsMultipleOpenReaders)
          {
              reader = new NHybridDataReader(reader);
          }
  
          _readersToClose.Add(reader);
          LogOpenReader();
          return reader;
      }
  </code></pre>
  
  <p>I suspect that it is Log.DebugFormat calling the System.IO.TextWriter.SyncTextWriter.WriteLine. But why is there no log4net stack frame in the error? </p>