Ver Mensaje Individual
  #1  
Antiguo Hace 4 Semanas
Nano Ramírez Nano Ramírez is offline
Registrado
 
Registrado: mar 2025
Posts: 9
Reputación: 0
Nano Ramírez Va por buen camino
Unhappy Bpl en RAD Studio 10.3 consumido en Delphi 2010

Buen día a todos. Tengo el siguiente bpl creado en RAD Studio 10.3:

Código Delphi [-]
unit unitConsumo; interface uses
System.SysUtils, System.Classes,Vcl.Dialogs, IdHTTP, IdSSLOpenSSLHeaders, IdIOHandler, IdIOHandlerSocket, IdIOHandlerStack, IdSSL, IdSSLOpenSSL, IdServerIOHandler, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient;
function pruebaString():string; stdcall; procedure prueba(); implementation procedure prueba(); begin ShowMessage('yes'); end; function pruebaString():string; stdcall; begin Result:='a ver si ya'; end; exports prueba, pruebaString ;



Dicho BPL lo consumo desde delphi 2010:

Código Delphi [-]
program pConsumoBplConsola; {$INCLUDE FastMM4Options.inc} {$APPTYPE CONSOLE} uses FastMM4 in 'FastMM4.pas', FastMM4LockFreeStack in 'FastMM4LockFreeStack.pas', FastMM4Messages in 'FastMM4Messages.pas', SysUtils, Windows; var token: WideString; H: THandle; obtenerToken: function(urlToken, grantType, clienteId, clienteSecreto, resource: string): WideString;stdcall; obtenerString : function(): string; stdcall; obtenerprueba : procedure(); begin ReportMemoryLeaksOnShutdown := true; FullDebugModeScanMemoryPoolBeforeEveryOperation := true; try ScanMemoryPoolForCorruptions; token := 'hola'; H := 0; obtenerToken := nil; obtenerprueba := nil; obtenerString := nil; try H := LoadPackage('ConsumoD365.bpl'); if H <> 0 then begin @obtenerString := GetProcAddress(H, 'pruebaString'); // @obtenerToken:=GetProcAddress(H,'getToken'); // @obtenerprueba:=GetProcAddress(H,'prueba'); if Assigned(obtenerString) then begin token := obtenerString(); { token:=obtenerToken( 'urlToken', 'grant_type', 'clienteId', 'clienteSecreto', 'resource'); } Writeln('*******************************'); Writeln(token); Writeln('*******************************'); end else begin Writeln('No se cargó la función'); end; end else begin Writeln('No se cargó el bpl'); end; except on E: Exception do Writeln('Error dentro;', E.ClassName, ': ', E.Message); end; finally if H <> 0 then begin FreeLibrary(H); end; end; Readln; end.



El problema es el siguiente:
Cuando consumo el BPL y utilizo el procedure funciona sin problema. Pero cuando utilizo una función del BPL me arroja errores de memoria.
El objetivo (como pueden ver en la variable comentada "{token:=obtenerToken(...}") es consumir una api que me retorne un token de acceso y sí lo hace correctamente pero el problema es el mismo, aparecen errores de memoria.
Pensé que sería un problema por los dcp que utiliza mi BPL para hacer la conexión, por lo que hice este ejemplo en donde la función retorne solamente un valor String y también lo regresa de forma correcta, pero persiste el problema de fuga de memoria.

He utilizado la herramienta FastMM4 y me arroja este reporte:


--------------------------------2025/3/27 18:06:48--------------------------------
FastMM has detected an error during a FreeMem operation. The block header has been corrupted.

The current thread ID is 0x358C, and the stack trace (return addresses) leading to this error is:
00403C56 [System.pas][System][FreeMem][3030]
00405D26 [System.pas][System][LStrArrayClr][13726]
00416394
77B1FCC9 [BaseThreadInitThunk]
77E67CBE [RtlGetAppContainerNamedObjectPath]
77E67C8E [RtlGetAppContainerNamedObjectPath]

Current memory dump of 256 bytes starting at pointer address 2AA8508:
B0 04 02 00 00 00 00 00 0B 00 00 00 61 00 20 00 76 00 65 00 72 00 20 00 73 00 69 00 20 00 79 00
61 00 00 00 01 00 00 00 B0 04 02 00 00 00 00 00 0B 00 00 00 74 00 70 00 65 00 72 00 73 00 69 00
73 00 74 00 65 00 6E 00 74 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
° . . . . . . . . . . . a . . v . e . r . . s . i . . y .
a . . . . . . . ° . . . . . . . . . . . t . p . e . r . s . i .
s . t . e . n . t . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Estos son los dcp usados por mi BPL:

bindcomp.dcp
bienengine.dcp
IndyCore.dcp
IndyProtocols.dcp
IndySystem.dcp
rtl.dcp
vcl.dcp
Agradezco de antemano la atención y ojalá alguien pueda apoyarme.
PD: soy nuevo el Delphi
Responder Con Cita