title: System.AccessViolationException happened in unknown module
body: <p>I have a program, which at unexplained times throws this error:</p>
  
  <blockquote>
    <p>System.AccessViolationException was unhandled<br>
    Message: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.</p>
  </blockquote>
  
  <p>This is an x64 binary under Windows Server 2008.
  If the program is compiled as an x86 binary, the problem is less frequent, but still occurs.</p>
  
  <p>The program is a server port program, it receives data from the network (UDP) and then send it to a user (if there is a user connected).</p>
  
  <p>It worked until I added LZMA.c# to compress the data.</p>
  
  <p>The LZMA.c# appears to be working correctly based on logging its functions.</p>
  
  <p>Now, even if I remove LZMA.c# from the program, it still crashes at seemingly random times.</p>
  
  <p>I can see nothing useful at the stack trace, it always looks like this:</p>
  
  <blockquote>
    <blockquote>
      <p>ntdll.dll!000000007771fefa()<br>
          [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll] 
          KernelBase.dll!000007fefd7a10ac()<br>
          clr.dll!000007fef47d45bf()<br>
          clr.dll!000007fef47d4577()<br>
          clr.dll!000007fef47d44f8()<br>
          clr.dll!000007fef4b523d2()<br>
          clr.dll!000007fef4b522f0()<br>
          clr.dll!000007fef4dd7b85()<br>
          clr.dll!000007fef4dd78ce()<br>
          clr.dll!000007fef4be74aa()<br>
          clr.dll!000007fef4d1163f()<br>
          clr.dll!000007fef4d14d1c()<br>
          clr.dll!000007fef4d14b77()<br>
          clr.dll!000007fef4d147e4()<br>
          clr.dll!000007fef4d10fc6()<br>
          clr.dll!000007fef4b79841()<br>
          clr.dll!000007fef4b7ca67()<br>
          clr.dll!000007fef4b789bc()<br>
          clr.dll!000007fef4b7babf()<br>
          clr.dll!000007fef4b516d2()<br>
          clr.dll!000007fef4d98fa4()<br>
          msvcr110_clr0400.dll!000007fef5b48ca6()<br>
          ntdll.dll!000000007770554d()<br>
          ntdll.dll!00000000776e5d1c()<br>
          ntdll.dll!000000007771fe48()<br>
          00000000f3468180()<br>
          clr.dll!000007fef481f713()<br>
          clr.dll!000007fef481f242()<br>
          clr.dll!000007fef481f30b()<br>
          clr.dll!000007fef48d27c1()<br>
          clr.dll!000007fef48c6d80()<br>
          clr.dll!000007fef48c6d0e()<br>
          clr.dll!000007fef48c6c85()<br>
          clr.dll!000007fef48c6dbb()<br>
          clr.dll!000007fef48d2728()<br>
          clr.dll!000007fef48c98cf()<br>
          clr.dll!000007fef48c97d3()<br>
          clr.dll!000007fef49566ae()<br>
          kernel32.dll!00000000775cf56d()<br>
          ntdll.dll!0000000077703281()    </p>
    </blockquote>
  </blockquote>
  
  <p>What's wrong is it?
  <em>(maybe it is crashing when gc is collecting garbage?)</em></p>