<div dir="ltr">Hello,<div><br></div><div>I got an AV in the CMem unit. To reproduce the problem just compile and run this code below:</div><div><br></div><div>=== code ===</div><div><br></div><div><div>program project1;</div><div><br></div><div>{$mode delphi}</div><div><br></div><div>uses</div><div>  Classes, SysUtils, cmem;</div><div><br></div><div>var</div><div>  VBuffer: TBytes;</div><div>  VStream: TStream;</div><div>begin</div><div>  VStream := TBytesStream.Create;</div><div>  try</div><div>    VBuffer := TEncoding.UTF8.GetBytes('abc');</div><div>    VStream.WriteBuffer(VBuffer[0], Length(VBuffer));</div><div>  finally</div><div>    VStream.Free;</div><div>  end;</div><div>end.</div></div><div><br></div><div>=== /code ===</div><div><br></div><div>=== error ===</div><div><br></div><div><div>C:\Users\silvioprog\Desktop\av>project1.exe</div><div>An unhandled exception occurred at $00410479:</div><div>EAccessViolation: Access violation</div><div>  $00410479</div><div>  $00410542</div><div><br></div><div>Heap dump by heaptrc unit</div><div>70 memory blocks allocated : 1972/2104</div><div>67 memory blocks freed     : 1792/1920</div><div>3 unfreed memory blocks : 180</div><div>True heap size : 262144 (96 used in System startup)</div><div>True free heap : 261632</div><div>Should be : 261672</div><div>Call trace for block $015C8480 size 64</div><div>  $00409B9C</div><div>  $004169A7</div><div>  $0040AACE</div><div>  $00410542</div><div>Call trace for block $015C0478 size 24</div><div>  $00409B9C</div><div>  $004169A7</div><div>  $0040AACE</div><div>  $00410542</div><div>Call trace for block $015B8470 size 92</div><div>  $0041687F</div><div>  $0040AACE</div><div>  $00410542</div><div>  $0077006F</div><div>  $005C0073</div><div>  $00790073</div><div>  $00740073</div><div>  $006D0065</div></div><div><br></div><div>=== /error ===</div><div><br></div><div>The project was compiled with -gh option. If you comment the "cmem" declaration, the problem is over.</div><div><br></div><div>To fix my problem I declared the functions Malloc() and Free() directly in my project, but even so I thought it was interesting to report this error.</div><div><div><br></div>-- <br><div><div dir="ltr"><div>Silvio Clécio</div></div></div>
</div></div>