Forum > General
Range Check Error is raised on FindFirst ($FFFFFFFF)
Awesome Programmer:
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 [+][-]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";}};} --- 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:
--- 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";}};} ---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:
So, the typecast of the const $FFFFFFFF, must be Longint($FFFFFFFF) i.e. always like this:
--- 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";}};} ---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:
Where does the $FFFFFFFF requirement come from anyway? In the FILUTILH.INC file the file attributes are listed as:
--- 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";}};} ---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 [+][-]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";}};} ---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 [+][-]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";}};} ---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:
Hello,
--- Quote from: devEric69 on September 23, 2021, 04:44:17 pm ---So, the typecast of the const $FFFFFFFF, must be Longint($FFFFFFFF) i.e. always like this:
--- 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";}};} ---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).
--- End quote ---
and why not using -1 ? :
--- 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";}};} ---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
Navigation
[0] Message Index
[#] Next page