Re: [fpc-devel] Published record

2024-08-18 Thread baldzhang via fpc-devel


you may try this:

TSomeObjToSerial = class(TPersistent)
private
  FPoint: TPoint;
public
  property Point: TPoint read FPoint write FPoint;
published
  property PointX: Integer read FPoint.x write FPoint.x;
  property PointY: Integer read FPoint.y write FPoint.y;
end;

not tested by compiler, but as I remeber it's work.
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


[fpc-devel] Is it possible to merge r43880 and r44093 to 3.2 ?

2020-02-12 Thread baldzhang via fpc-devel
r43880 (fix #0036528) 
and 
r44093 (fix #0034416)

hope it is not too late to merge them.

BTW: it first time I try to post messages to mailing list, if this one 
duplicated, please ignore first one.
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


[fpc-devel] merge requests

2020-02-12 Thread baldzhang via fpc-devel
Hi, is it possible to merge r43880 (fix #0036528) and r44093 (fix #0034416) to 
fixes_3_2 ?
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


[fpc-devel] Is it still possiblility to merge r43880 and r44093 to 3.2 ?

2020-05-22 Thread baldzhang via fpc-devel
Hi,

I mentioned this two revisions before 3.2 was tagged, and marcov said will 
merge them later.
Until now, they are not done yet.

I post some more detail at here:
https://forum.lazarus.freepascal.org/index.php/topic,48361.0.html

Hopefully they could be merged to 3.2 before we get a release.

Thanks.
baldzhang
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


[fpc-devel] certificate verify issue of tfphttpclient with openssl

2020-08-21 Thread baldzhang via fpc-devel
certificate verify issue of tfphttpclient with openssl

from wiki page, https client as easy as:
  tfphttpclient.simpleget('https://192.168.0.1')

in TOpenSSLSocketHandler, the VerifyPeerCert is False by default
when check the TSSL.VerifyResult, will got one of following:

1) X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT = 18;
  when https server use a self-signed cert

2) X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN = 19;
  when server use a cert signed by internal CA

3) X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY = 20;
  when connect to a real *signed* server, ex: https://www.kernel.org

if set TSSL.VerifyResult to True, the connect will fail and exception raised.
even set Handler.CertificateData.CertCA.FileName to a valid cert file.

finally found in opensslsockets.pas: TOpenSSLSocketHandler.Connect: Boolean
...
 if Result and VerifyPeerCert then
   Result:=(FSSL.VerifyResult<>0) or (not DoVerifyCert);
...
in first Result and VerifyPeerCert both are True
the second line, if I'm not wrong understanding, is totally reverse

FSSL.VerifyResult is 0 here, and DoVerifyCert always return True,
so the Result changed to False, and then the connect became fail.


in a real prog, we want to check the VerifyResult, and still allow the 
connection in some conditions.

after some modify, things changed to:

1) when VerifyPeerCert is True 
  if Handler.CertificateData.CertCA.FileName set to a valid cert,
  VerifyResult will be 0, and https request passed

2) when it's False
   assign a OnVerifyCertificate handler, check SSL infos, to allow or deny the 
connect.


*** tested fpc 3.2.0, openssl 1.0.2j(copied from lazarus), windows 10 64-bit, 
client side of https transmition.

patch file attached,
some explain:

a) sslsockets.pp
  the TVerifyCertificateEvent shall allow to modify the "Allow" param, for 
compatibility reason, 
  function DoVerifyCert: Boolean may change to virtual

b) fppoenssl.pp
  FingerPrint always genarate by MD5, can be SHA1 or SHA256

c) opensslsockets.pp
  export SSL: TSSL for more lower level control
  in Connect():
Result and VerifyPeerCert check are duplicated
alway give a chance to let user do the certificate verifing.


openssl-verify-cert.diff
Description: Binary data
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] certificate verify issue of tfphttpclient with openssl

2020-08-22 Thread baldzhang via fpc-devel
At 2020-08-22 06:28:55, "Michael Van Canneyt via fpc-devel" 
 wrote:
>
>On Sat, 22 Aug 2020, baldzhang via fpc-devel wrote:
>
>Patch checked and applied in rev. 46540
>
>谢谢您,这个很有用!
>
>Michael.

Thanks for the hard work of pascal team :)
Is this possible to merge back to 3.2 ?

BTW: Very surprised when I saw the chinese words :D
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


[fpc-devel] about #0035991, fpc 3.2.1 still crash lazarus 2.0.10, 2.0.11

2020-08-31 Thread baldzhang via fpc-devel
Hi, Ondrej 

I saw you mark #0035991 resolved, but I still has crash problem on 
Svn2RevisionInc.

The testing result is:
3.2.0
  2.0.10
  2.0.11
  2.1 : all good

3.2.1
  2.0.10  : exception
  2.0.11  : exception
  2.1 : good

This was tested with a small program copy from Svn2RevisionInc, and compiled 
with different version's lazutils source codes.
(source code attached)

The exceptions are raised from same location, a dump from svn2revisioninc looks 
like:

An unhandled exception occurred at $0001A13A:
EAccessViolation: Access violation
  $0001A13A fpc_ansistr_decr_ref, line 146 of ../inc/astrings.inc
  $000100012921 fpc_finalize, line 234 of ../inc/rtti.inc
  $000100012657 RECORDRTTI, line 134 of ../inc/rtti.inc
  $000100010C91 CLEANUPINSTANCE, line 755 of ../inc/objpas.inc
  $000100010489 FREEINSTANCE, line 446 of ../inc/objpas.inc
  $00010004529A DESTROY, line 277 of fcl-process/src/processbody.inc
  $00011962 fin$0012, line 118 of svn2revisioninc.pas
  $000119ED SVNINPATH, line 109 of svn2revisioninc.pas
  $00013C91 PARAMSVALID, line 572 of svn2revisioninc.pas
  $000146DD GITREVISIONFROMGITCOMMIT, line 769 of svn2revisioninc.pas
  $000147C7 main, line 788 of svn2revisioninc.pas
  $000147E6 MAIN_WRAPPER, line 126 of system.pp
  $00010001AE27 EXE_ENTRY, line 240 of system.pp
  $0001192D _FPC_MAINCRTSTARTUP, line 106 of sysinit.pp
  $7FFB4D7B7BD4
  $7FFB4E96CE51


I write some note in bug tracker, you may not noticed yet.

So my question is:
Is there any plan to fix it with this bundle(fpc 3.2.x/lazarus 2.0.x)? Or 
lazarus 2.0.x will stick on fpc 3.2.0? 

Because I need fpc 3.2.1 with new ssl features but did not  want to maintain 
extra patches when building fpc/lazarus.

Thanks.
B. Zhang


proc.lpr
Description: Binary data
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] about #0035991, fpc 3.2.1 still crash lazarus 2.0.10, 2.0.11

2020-09-02 Thread baldzhang via fpc-devel
Hi, Ondrej

> At 2020-09-02 17:37:19, "Ondrej Pokorny via fpc-devel" 
>  wrote:

> it is not possible to support the latest FPC trunk in already
>   released Lazarus versions (2.0.10).

Got it.
 
> If you want some bug fixes to be merged into the stable branch
>   (currently 2.0.11), you can list the revisions here:
>
>   https://wiki.freepascal.org/Lazarus_2.0_fixes_branch
>
> I did it for you now for the two revisions of issue 35991.
 
This is what I hoped to, and I will try in the future.

Thank you.

B. Zhang.
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] double free of internal temp string with fpc 3.2.0

2021-01-08 Thread baldzhang via fpc-devel
I have the same problem after upgrade to 3.2.0, 3.0.4 is all good.

In my program, when free a TStringList that used in a thread, exception occurs 
in 80%~90% time.
I try to finger out what happening and got fpc_ansistr_decr_ref calling FreeMem 
then got wrong memory.
The program was x86-64 on Windows 10.

I haven't dig so deep like Martin has done, but I think it's the same problem.


At 2021-01-09 00:11:19, "Martin Frb via fpc-devel" 
 wrote:
>I only tested with 3.2.0 so far. Maybe someone recalls if this is fixed 
>or not.
>
>Also because it seems to happen only in very rare conditions, it may be 
>that trunk does not cause it in this place even if the bug is not yet 
>fixed. (as other code changes could simply change the context enough to 
>mitigate it)
>
>
>Using fpc 3.2.0
>compiling lazarus  SVN 64346@trunk with -gw -gl -gt -Criot -Sa -O-1 -gh -gv
>(this also happened at -O3 / but I could not trace it as valgrinds 
>reported stack was unreadable  / The attached valgrind is with -O-1)
>
>unit MaskEdit
>procedure TCustomMaskEdit.SetMask(Value : String);
>
> From the generated ASM
>
># Temps allocated between rbp-696 and rbp-296
>
># [575] for I := 1 To Utf8Length(S) do
>     leaq    -400(%rbp),%rdi
>     call    fpc_ansistr_decr_ref@PLT
>     leaq    -408(%rbp),%rdi
>     call    fpc_ansistr_decr_ref@PLT
>     leaq    -272(%rbp),%rsi
>     xorl    %edx,%edx
>     leaq    -408(%rbp),%rdi
>     call    fpc_shortstr_to_ansistr@PLT
>     movq    -408(%rbp),%rsi   // 
><<
>     movq    %rsi,-400(%rbp)
>     testq    %rsi,%rsi
>     je    .Lj156
>     movq    -8(%rsi),%rsi
>.Lj156:
>     movq    -400(%rbp),%rdi
>     testq    %rdi,%rdi
>     jne    .Lj157
>     movq    FPC_EMPTYCHAR@GOTPCREL(%rip),%rdi
>.Lj157:
>     call    LAZUTF8_$$_UTF8LENGTH$PCHAR$INT64$$INT64@PLT
>
>On the marked line, the string (ref) in temp(-408) is copied to temp(-400).
>But the refcount is NOT increased
>
>*
>Temp(-408) is later passed as "var param Result" to
>
># [741] FTextOnEnter := inherited RealGetText;
>     movq    -16(%rbp),%rdi
>     leaq    -408(%rbp),%rsi
>     call STDCTRLS$_$TCUSTOMEDIT_$__$$_REALGETTEXT$$TTRANSLATESTRING@PLT
>
>This will assign an empty string (in this case), and free the memory 
>(apparently the refcount happens to be 1 at that time)
>
>*
>in the autogenerated code for the procedures "end" statement:
>
># [743] end;
>     leaq    -408(%rbp),%rdi
>     call    fpc_ansistr_decr_ref@PLT
>     leaq    -400(%rbp),%rdi
>     call    fpc_ansistr_decr_ref@PLT
>
>Temp-408 is already free (or may have a new value that gets correctly freed)
>
>Temp-400 still points to the already freed string => double free.
>
>
>
>
>
>
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


[fpc-devel] Hi Michael, have a look of #0038677

2021-04-09 Thread baldzhang via fpc-devel
https://bugs.freepascal.org/view.php?id=38677

a bug that parse PeerName error in fpopenssl
I remember you maintenance this.

Thanks.
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel