[fpc-pascal] CMem issue?
    silvioprog 
    silvioprog at gmail.com
       
    Tue Mar  8 01:50:57 CET 2016
    
    
  
Hello,
I got an AV in the CMem unit. To reproduce the problem just compile and run
this code below:
=== code ===
program project1;
{$mode delphi}
uses
  Classes, SysUtils, cmem;
var
  VBuffer: TBytes;
  VStream: TStream;
begin
  VStream := TBytesStream.Create;
  try
    VBuffer := TEncoding.UTF8.GetBytes('abc');
    VStream.WriteBuffer(VBuffer[0], Length(VBuffer));
  finally
    VStream.Free;
  end;
end.
=== /code ===
=== error ===
C:\Users\silvioprog\Desktop\av>project1.exe
An unhandled exception occurred at $00410479:
EAccessViolation: Access violation
  $00410479
  $00410542
Heap dump by heaptrc unit
70 memory blocks allocated : 1972/2104
67 memory blocks freed     : 1792/1920
3 unfreed memory blocks : 180
True heap size : 262144 (96 used in System startup)
True free heap : 261632
Should be : 261672
Call trace for block $015C8480 size 64
  $00409B9C
  $004169A7
  $0040AACE
  $00410542
Call trace for block $015C0478 size 24
  $00409B9C
  $004169A7
  $0040AACE
  $00410542
Call trace for block $015B8470 size 92
  $0041687F
  $0040AACE
  $00410542
  $0077006F
  $005C0073
  $00790073
  $00740073
  $006D0065
=== /error ===
The project was compiled with -gh option. If you comment the "cmem"
declaration, the problem is over.
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.
-- 
Silvio Clécio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20160307/20e5c64e/attachment.html>
    
    
More information about the fpc-pascal
mailing list