Range Check Error is raised on FindFirst ($FFFFFFFF) lazarus / 62-General ---------------------------------------------------------------------- Awesome Programmer · 2018-03-19 20:52 I've been having issues debugging my program on Lazarus. Every time I try to debug my program files and I get External: SIGILL error and debugging stops with Assembly code being displayed right after. However, my program runs with no problem if I run the executable outside of Lazarus compiler. So, I enabled Range Check Error option under Debugging in the Project Option. When I tried to debug, Lazarus immediately took me to Synaser file: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   procedure ScanForPorts( const ThisRootStr : string); // added by PDF  var theDevice : String;  var FD : Cint;  var Ser : TSerialStruct;  begin  if FindFirst( ThisRootStr, $FFFFFFFF, sr) = 0 then <<<<<<<<<<<<<<<<<<< Raised Range Check Error here.     begin      repeat        if (sr.Attr and $FFFFFFFF) = Sr.Attr then        begin So, my question is this. Is this a real bug in Synaser? if so, how do you go about fixing it. I think, Lazarus is complaining about $FFFFFFFF. ---------------------------------------------------------------------- Bart · 2018-03-19 21:07 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Function FindFirst (Const Path : RawByteString; Attr : Longint; out Rslt : TRawByteSearchRec) : Longint;  Attr is declared as LongInt, so $FFFFFFFF will be out of range? Bart ---------------------------------------------------------------------- devEric69 · 2021-09-23 14:44 So, the typecast of the const $FFFFFFFF, must be Longint($FFFFFFFF) i.e. always like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i if FindFirst('/dev/ttyS*', Longint($FFFFFFFF), sr) = 0 then    repeat    if (sr.Attr and Longint($FFFFFFFF)) = Sr.Attr then...\... For information, I've just made a bug report about this range check error in synaser.pas, function GetSerialPortNames there (in Synapse 40.1.0.0). ---------------------------------------------------------------------- Graham1 · 2021-09-26 02:13 Where does the $FFFFFFFF requirement come from anyway? In the FILUTILH.INC file the file attributes are listed as: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Const  { File attributes }  faReadOnly   = $00000001;  faHidden     = $00000002 platform;  faSysFile    = $00000004 platform;  faVolumeId   = $00000008 platform deprecated;  faDirectory  = $00000010;  faArchive  = $00000020;  faNormal     = $00000080;  faTemporary  = $00000100 platform;  faSymLink    = $00000400 platform;  faCompressed = $00000800 platform;  faEncrypted  = $00004000 platform;  faVirtual    = $00010000 platform;  faAnyFile    = $000001FF; Even if you AND all of these to see every possible file type you don't get to $FFFFFFFF. I find these flags work fine in my version of the search for ports routine: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function GetSerialPortNames: string;var  ports : string;  flags : Longint;  rec   : TSearchRec;        procedure ScanForPorts(const ThisRootStr:string; ValidateIO:boolean=false);   var      devnam : string;      FD     : cInt;      ser    : TSerialStruct;      usedev : boolean;   begin      if FindFirst(ThisRootStr, flags, rec) = 0 then begin         repeat            if (rec.Attr and flags) = rec.Attr then begin               devnam := '/dev/' + rec.Name;               FD := fpopen(devnam, O_RdWr or O_NonBlock or O_NoCtty);               if FD > 0 then begin                  if not ValidateIO then                   usedev:=true                  else begin                   usedev:=false;                     if fpioctl(FD, TIOCGSERIAL, @ser) <> -1 then                        if ser.typ <> 0  then                         usedev:=true;                  end;                  if usedev then begin                     if ports <> '' then                      ports := ports + ',' + rec.Name                     else                      ports := rec.Name;                  end;                fpclose(FD);               end;            end;         until FindNext(rec) <> 0;      end;   end;     begin   ports := '';   flags := faAnyFile AND (NOT faDirectory);   try      ScanForPorts('/dev/ttyS*',true);      ScanForPorts('/dev/rfcomm*');    ScanForPorts('/dev/ttyUSB*');      ScanForPorts('/dev/ttyACM*');    FindClose(rec);   finally      result := ports;   end;end; where: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses   termio, baseunix, classes, sysutils; type   TSerialStruct = packed record         typ             : Integer;         line            : Integer;         port            : Cardinal;         irq             : Integer;         flags           : Integer;         xmit_fifo_size  : Integer;         custom_divisor  : Integer;         baud_base       : Integer;         close_delay     : Word;         io_type         : Char;         reserved_char   : Char;         hub6            : Integer;         closing_wait    : Word; // time to wait before closing         closing_wait2   : Word; // no longer used...         iomem_base      : ^Char;         iomem_reg_shift : Word;         port_high       : Cardinal;         iomap_base      : LongWord; // cookie passed into ioremap       end; ---------------------------------------------------------------------- Jurassic Pork · 2022-11-10 06:17 Hello, Quote from: devEric69 on September 23, 2021, 04:44:17 pmSo, the typecast of the const $FFFFFFFF, must be Longint($FFFFFFFF) i.e. always like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i if FindFirst('/dev/ttyS*', Longint($FFFFFFFF), sr) = 0 then    repeat    if (sr.Attr and Longint($FFFFFFFF)) = Sr.Attr then...\... For information, I've just made a bug report about this range check error in synaser.pas, function GetSerialPortNames there (in Synapse 40.1.0.0). and why not using -1  ? : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i if FindFirst('/dev/ttyS*', -1, sr) = 0 then    repeat      if (sr.Attr and  -1) = Sr.Attr then...\... but the Graham1's code seems more logical. I have tried his code in the lazsynaser.pas file of the Lazserial package. OK on Ubuntu 20.04 Lazarus 2.2 with two USB serial ports. Friendly, J.P ---------------------------------------------------------------------- jamie · 2022-11-10 23:16 Quote from: Jurassic Pork on November 10, 2022, 07:17:21 amHello, Quote from: devEric69 on September 23, 2021, 04:44:17 pmSo, the typecast of the const $FFFFFFFF, must be Longint($FFFFFFFF) i.e. always like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i if FindFirst('/dev/ttyS*', Longint($FFFFFFFF), sr) = 0 then    repeat    if (sr.Attr and Longint($FFFFFFFF)) = Sr.Attr then...\... For information, I've just made a bug report about this range check error in synaser.pas, function GetSerialPortNames there (in Synapse 40.1.0.0). and why not using -1  ? : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i if FindFirst('/dev/ttyS*', -1, sr) = 0 then    repeat      if (sr.Attr and  -1) = Sr.Attr then...\... but the Graham1's code seems more logical. I have tried his code in the lazsynaser.pas file of the Lazserial package. OK on Ubuntu 20.04 Lazarus 2.2 with two USB serial ports. Friendly, J.P Good One J.P.  I was reading this, and I said come on, I want to answer this one, but J.P. beat me to it!