View Issue Details

IDProjectCategoryView StatusLast Update
0035450FPCPackagespublic2019-10-03 05:48
ReporterCudaText manAssigned ToPierre Muller 
PrioritynormalSeverityminorReproducibilityalways
Status confirmedResolutionopen 
Product Version3.3.1Product Build 
Target VersionFixed in Version 
Summary0035450: RegExpr test app, cross compiled to Solaris x64, fails
DescriptionHost: Linux x64, fpcupdeluxe 1.6.2u (today version), FPC cross lib installed for Solaris x64
Attached demo.
Make this demo for Solaris, and run on Solaris (with Gnome shell).

On Win/Linux, demo shows ok result: "ok match"
On Solaris, demo shows "no match", ie RegExpr unit (from FPC) cannot find string by regex
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files
  • test_regex_match_loop.zip (4,511 bytes)
  • test-regex.pp (1,563 bytes)
    uses
      Classes, SysUtils,   regexpr;
    
    type
      TRegexParts = array[0..8] of
        record
          Pos, Len: integer;
          Str: string;
        end;
    
    function SRegexFindParts(const ARegex, AStr: string; out AParts: TRegexParts): string;
    var
      Obj: TRegExpr;
      i: integer;
    begin
      Result:= '';
      for i:= Low(AParts) to High(AParts) do
      begin
        AParts[i].Pos:= -1;
        AParts[i].Len:= 0;
        AParts[i].Str:= '';
      end;
    
      if ARegex='' then exit;
      if AStr='' then exit;
    
      Obj:= TRegExpr.Create;
      try
        Obj.ModifierS:= false; //don't catch all text by .*
        Obj.ModifierM:= true; //allow to work with ^$
        Obj.ModifierI:= false;
    
        try
          Obj.Expression:= ARegex;
          Obj.InputString:= AStr;
          //Result:=
          Obj.ExecPos(1);
          if Obj.MatchPos[0]<=0 then
            Result:= 'no match';
        except
          on e: Exception do
            Result:= e.Message;
        end;
    
        if Result='' then
        begin
          for i:= Low(AParts) to High(AParts) do
          begin
            AParts[i].Pos:= Obj.MatchPos[i];
            AParts[i].Len:= Obj.MatchLen[i];
            AParts[i].Str:= Obj.Match[i];
          end;
        end;
      finally
        FreeAndNil(Obj);
      end;
    end;
    
    const
      cRegex_SignFunc = 'module=(.+?);func=(.+?);(info=(.+?);)?$';
    var
      Parts: TRegexParts;
      Regex, Res: string;
    begin
      Regex:= 'module=ttttttttttt;func=_dlg_dddddddddddddddddddd;info="dddddddddddddddd:<function DlgAgent._ddddddd.<locals>.ddddddddddddd at 0x7ffffffffffffffffff>";';
    
      Res:= SRegexFindParts(cRegex_SignFunc, Regex, Parts);
      if Res='' then Res:= 'ok match';
      Res:= ': '+Res;
      writeln(Res);
    
    end.
    
    test-regex.pp (1,563 bytes)

Activities

CudaText man

2019-04-26 14:15

reporter  

test_regex_match_loop.zip (4,511 bytes)

Pierre Muller

2019-04-26 17:18

developer   ~0115826

  Hi,

  please try to submit code that can be compiled with a simpe FPC installation
when your bug report is about Free Pascal compiler or packages.

  I simplified your code to test it, and cross-compiled it from
linux to sparc-solaris without getting a different behavior.
  Please try new attached test source code and let us know if you get the same
issue for this simplified code.

Pierre Muller

Pierre Muller

2019-04-26 17:19

developer   ~0115827

New simplified test code

test-regex.pp (1,563 bytes)
uses
  Classes, SysUtils,   regexpr;

type
  TRegexParts = array[0..8] of
    record
      Pos, Len: integer;
      Str: string;
    end;

function SRegexFindParts(const ARegex, AStr: string; out AParts: TRegexParts): string;
var
  Obj: TRegExpr;
  i: integer;
begin
  Result:= '';
  for i:= Low(AParts) to High(AParts) do
  begin
    AParts[i].Pos:= -1;
    AParts[i].Len:= 0;
    AParts[i].Str:= '';
  end;

  if ARegex='' then exit;
  if AStr='' then exit;

  Obj:= TRegExpr.Create;
  try
    Obj.ModifierS:= false; //don't catch all text by .*
    Obj.ModifierM:= true; //allow to work with ^$
    Obj.ModifierI:= false;

    try
      Obj.Expression:= ARegex;
      Obj.InputString:= AStr;
      //Result:=
      Obj.ExecPos(1);
      if Obj.MatchPos[0]<=0 then
        Result:= 'no match';
    except
      on e: Exception do
        Result:= e.Message;
    end;

    if Result='' then
    begin
      for i:= Low(AParts) to High(AParts) do
      begin
        AParts[i].Pos:= Obj.MatchPos[i];
        AParts[i].Len:= Obj.MatchLen[i];
        AParts[i].Str:= Obj.Match[i];
      end;
    end;
  finally
    FreeAndNil(Obj);
  end;
end;

const
  cRegex_SignFunc = 'module=(.+?);func=(.+?);(info=(.+?);)?$';
var
  Parts: TRegexParts;
  Regex, Res: string;
begin
  Regex:= 'module=ttttttttttt;func=_dlg_dddddddddddddddddddd;info="dddddddddddddddd:<function DlgAgent._ddddddd.<locals>.ddddddddddddd at 0x7ffffffffffffffffff>";';

  Res:= SRegexFindParts(cRegex_SignFunc, Regex, Parts);
  if Res='' then Res:= 'ok match';
  Res:= ': '+Res;
  writeln(Res);

end.
test-regex.pp (1,563 bytes)

CudaText man

2019-04-26 20:47

reporter   ~0115832

I use Solaris x86_64 (not SPARC)
Yes, same bug behavious.
From Solaris console:

alex@pc:~/Downloads$ ./test-regex
bash: ./test-regex: Permission denied
alex@pc:~/Downloads$ chmod a+x test-regex
alex@pc:~/Downloads$ ./test-regex
: no match
alex@pc:~/Downloads$

Pierre Muller

2019-04-26 23:04

developer   ~0115835

  I compiled the simplified source code for x86_64-solaris
system natively, and got the same output.

  This means:
1) There is indeed a different output for x86-64 CPU (both sparc and i386 executables return ok)
2) It is not a cross-compilation issue.

Which probably means that it is a CPU specific code generation issue.

CudaText man

2019-10-03 05:48

reporter   ~0118267

Hi, any progress with the issue?

Issue History

Date Modified Username Field Change
2019-04-26 14:15 CudaText man New Issue
2019-04-26 14:15 CudaText man File Added: test_regex_match_loop.zip
2019-04-26 17:18 Pierre Muller Assigned To => Pierre Muller
2019-04-26 17:18 Pierre Muller Status new => feedback
2019-04-26 17:18 Pierre Muller Note Added: 0115826
2019-04-26 17:19 Pierre Muller File Added: test-regex.pp
2019-04-26 17:19 Pierre Muller Note Added: 0115827
2019-04-26 20:47 CudaText man Note Added: 0115832
2019-04-26 20:47 CudaText man Status feedback => assigned
2019-04-26 23:04 Pierre Muller Status assigned => confirmed
2019-04-26 23:04 Pierre Muller Note Added: 0115835
2019-10-03 05:48 CudaText man Note Added: 0118267