Recent

Author Topic: UpCase Crash with this code.  (Read 799 times)

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8496
  • FPC developer.
Re: UpCase Crash with this code.
« Reply #15 on: April 05, 2020, 04:22:45 pm »
This morning I double checked the ansipropstr implementation, but it first calls result:=asnilowercase(s) which calls uniquestring (and since rev 1) for anything but an empty string.

After that it only touches the result variable.

That said, since ansilowercase is a widestringmanager function, I only checked the Windows variant(since that was what the bugreport was about).

Jamie: on what target could you reproduce? Theoretically it could be widestringmanager.ansilowercase implementation of that target missing an uniquestring.

I can produce that with a  simple laz app on Windows 10 using laz 2.0.6 and 3.0.4..

and it's UpCase that is the issue because AnsiProperCase using that internally..

 I wouldn't worry too much about it because my old D3 faults on UpCase in the same manner.. there is no call to UniquieString in the background.

and I am using LongSrings of course

Please read my message carefully. AnsiPropCase calls AnsiLowerCase that is OS dependent. The Windows version has uniquestring, but if some other OS doesn't, that is a bug.

So again, on which target did you test AnsiPropCase?

bug reference: https://bugs.freepascal.org/view.php?id=36866

jamie

  • Hero Member
  • *****
  • Posts: 3141
Re: UpCase Crash with this code.
« Reply #16 on: April 05, 2020, 04:35:33 pm »
I don't know what the issue is here. I have stated it several times.. This is the source code that gets
excuted.

Code: Pascal  [Select][+][-]
  1. function AnsiProperCase(const S: string; const WordDelims: TSysCharSet): string;
  2.  
  3. var
  4.   P,PE : PChar;
  5.  
  6. begin
  7.   Result:=AnsiLowerCase(S);
  8.   P:=PChar(pointer(Result));
  9.   PE:=P+Length(Result);
  10.   while (P<PE) do
  11.     begin
  12.     while (P<PE) and (P^ in WordDelims) do
  13.       inc(P);
  14.     if (P<PE) then
  15.       P^:=UpCase(P^);  // <<<<< You see here
  16.     while (P<PE) and not (P^ in WordDelims) do
  17.       inc(P);
  18.     end;
  19. end;
  20.  
  21.  

This is from 2.0.6 and 2.0.4 of 3.0.4 Fpc generating a 64 bit windows target.

from the unit "strUtils"

If I copy and paste that code within a local call it will crash where I indicated...
The only true wisdom is knowing you know nothing

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8496
  • FPC developer.
Re: UpCase Crash with this code.
« Reply #17 on: April 05, 2020, 04:51:49 pm »

This is from 2.0.6 and 2.0.4 of 3.0.4 Fpc generating a 64 bit windows target.

from the unit "strUtils"

If I copy and paste that code within a local call it will crash where I indicated...

Copy and pasted it, used the calling code from the bug report. Tested with FPC 3.3.1 64-bit (since I don't have 3.0.4 64-bit), everything fine.

As said, if it does, it is probably not related to the literal thingy, since ansilowercase does uniquestring() already.

jamie

  • Hero Member
  • *****
  • Posts: 3141
Re: UpCase Crash with this code.
« Reply #18 on: April 05, 2020, 05:16:24 pm »
This is my last post on this, I am sure it will make many happy...
I know the issue but others claim its not happening on their end with the supposed same tool versions.
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018