Forum > Unix

FPC320 lib for SSL

(1/2) > >>

mm7:
There are know issues with libssl v1.1 in FPC304.
I've decided to work it around by building my little library in FPC320 and then use it from program in FPC304.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---library freehttpslib;{$mode objfpc}{$H+} uses  Classes, SysUtils,  fphttpclient, fpopenssl, OpenSSL, ssockets, opensslsockets,  strutils; function https_get(url:string):RawByteString; cdecl;var Client: TFPHttpClient;begin   Result := '';   InitSSLInterface;   Client := TFPHttpClient.Create(nil);   try     Client.AddHeader('User-Agent','Mozilla/5.0 (compatible; fpweb)');     Client.AllowRedirect := true;     //URL:='https://google.com/';     Result := Client.Get(URL);   finally     Client.Free;   end;end; const  Prefix = {$if defined(unix)}'lib'           {$elseif freebsd}'lib'           {$else}''           {$endif};exports  https_get name Prefix+'https_get';end. The library is built fine.

Program

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program project1;{$mode objfpc}{$H+} {$IF FPC_FULLVERSION < 32000}function libhttps_get(url:string):RawByteString; cdecl; external 'libfreehttpslib.so';{$endif} var R: RawByteString;begin  R := libhttps_get('https://google.com');  writeln(R);end. The program is built fine.

But it fails when I run it

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---mark@ustudio:~/MyProjects/fpc/https32$ ldd project1         linux-vdso.so.1 (0x00007fff2a71e000)        libfreehttpslib.so => /usr/local/lib/libfreehttpslib.so (0x00007f43b6fe6000)        /lib64/ld-linux-x86-64.so.2 (0x00007f43b6f3f000)        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f43b6d3b000)        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f43b694a000)mark@ustudio:~/MyProjects/fpc/https32$ ./project1 Inconsistency detected by ld.so: dl-minimal.c: 126: realloc: Assertion `ptr == alloc_last_block' failed! 
why?

Cyrax:
Use PChar type instead of String type.

mm7:
just tryed. Same error
Inconsistency detected by ld.so: dl-minimal.c: 126: realloc: Assertion `ptr == alloc_last_block' failed!

Cyrax:
Run your program under strace utility and see what your program really doing when its running.

Cyrax:
See this stackoverflow post : https://stackoverflow.com/questions/59956996/problem-loading-a-library-with-ffi-in-php-7-4/59994038#59994038

Navigation

[0] Message Index

[#] Next page

Go to full version