Discussion:
[Lazarus] Unknown error codes.
Carlos E. R. via Lazarus
2018-04-29 19:00:31 UTC
Permalink
Hi,

The other day I got this error in a program (on Linux):

***@Telcontar:~/bin/lazarus/mios> ./crc32test ./crc32test
An unhandled exception occurred at $0000000000400951:
EInOutError: Unknown Run-Time error : 026
$0000000000400951 line 26 of crc32test.lpr
$0000000000400A5C line 42 of crc32test.lpr

crc32 = ***@Telcontar:~/bin/lazarus/mios>


Notice the "Unknown" there. And indeed, error 26 is not listed here:

<https://www.freepascal.org/docs-html/rtl/system/ioresult.html>


A friend pointed me to this file:

/usr/include/asm-generic/errno-base.h

and there it is indeed listed:

#define ETXTBSY 26 /* Text file busy */

The error number does match the situation: the IDE has hold of that file
for debugging. Interesting.


But the problem is, why is that error not listed, unknown?

Today a poster wrote about this other error (subject: [Lazarus] Runtime
error: INCLOCKED):

Runtime error 216 at $0000000000400BD5
$0000000000400BD5 INCLOCKED
$0000000000400216 DISPLAY, line 23 of project1.lpr
$0000000000400360 main, line 32 of project1.lpr
$000000000042BE00 SYSENTRY, line 129 of system.pp
$00000000004001D2


which is not listed. I do not know if he is running Linux or Windows, so
I have no idea either what the error is in his case.

Do we know of more places that list those error numbers? Can we compose
a full list?

By the way, C has a function: "strerror(26)" which returns the text
message for the error. I don't know if we have.
--
Cheers / Saludos,

Carlos E. R.
(from 42.3 x86_64 "Malachite" at Telcontar)
Donald Ziesig via Lazarus
2018-04-29 20:07:56 UTC
Permalink
Post by Carlos E. R. via Lazarus
Hi,
EInOutError: Unknown Run-Time error : 026
$0000000000400951 line 26 of crc32test.lpr
$0000000000400A5C line 42 of crc32test.lpr
<https://www.freepascal.org/docs-html/rtl/system/ioresult.html>
/usr/include/asm-generic/errno-base.h
#define ETXTBSY 26 /* Text file busy */
The error number does match the situation: the IDE has hold of that file
for debugging. Interesting.
But the problem is, why is that error not listed, unknown?
Today a poster wrote about this other error (subject: [Lazarus] Runtime
Runtime error 216 at $0000000000400BD5
$0000000000400BD5 INCLOCKED
$0000000000400216 DISPLAY, line 23 of project1.lpr
$0000000000400360 main, line 32 of project1.lpr
$000000000042BE00 SYSENTRY, line 129 of system.pp
$00000000004001D2
which is not listed. I do not know if he is running Linux or Windows, so
I have no idea either what the error is in his case.
Do we know of more places that list those error numbers? Can we compose
a full list?
By the way, C has a function: "strerror(26)" which returns the text
message for the error. I don't know if we have.
216 is a General Protection Fault.

for other errors see: https://freepascal.org/docs-html/user/userap4.html

Don Ziesig
Carlos E. R. via Lazarus
2018-04-29 21:55:59 UTC
Permalink
Post by Donald Ziesig via Lazarus
Post by Carlos E. R. via Lazarus
Hi,
EInOutError: Unknown Run-Time error : 026
$0000000000400951 line 26 of crc32test.lpr
$0000000000400A5C line 42 of crc32test.lpr
<https://www.freepascal.org/docs-html/rtl/system/ioresult.html>
/usr/include/asm-generic/errno-base.h
...
Post by Donald Ziesig via Lazarus
Post by Carlos E. R. via Lazarus
Runtime error 216 at $0000000000400BD5
$0000000000400BD5 INCLOCKED
$0000000000400216 DISPLAY, line 23 of project1.lpr
$0000000000400360 main, line 32 of project1.lpr
$000000000042BE00 SYSENTRY, line 129 of system.pp
$00000000004001D2
...
Post by Donald Ziesig via Lazarus
216 is a General Protection Fault.
for other errors see:  https://freepascal.org/docs-html/user/userap4.html
It does not list the error 26 I got.

It is possible that there are different numbers on different operating
systems? That list seems to be related to Windows, but the link does not
say.
--
Cheers / Saludos,

Carlos E. R.
(from 42.3 x86_64 "Malachite" at Telcontar)
Rik van Kekem via Lazarus
2018-05-01 08:48:31 UTC
Permalink
This post might be inappropriate. Click to display it.
Carlos E. R. via Lazarus
2018-05-01 10:43:12 UTC
Permalink
Post by Rik van Kekem via Lazarus
Post by Carlos E. R. via Lazarus
It does not list the error 26 I got.
It is possible that there are different numbers on different operating
systems? That list seems to be related to Windows, but the link does not
say.
It's always possible to get the text of an OS error via SysErrorMessage().
Ah! I have been looking for such a function for hours. Yesterday I created my own functions to output text, getting the help from several help sources. Ok, Scrap those!
Post by Rik van Kekem via Lazarus
Also note that the EInOutError codes in the range 0-99 represent OS
error conditions, which are different for Windows and Linux. At least in
Delphi they do.
Ok.
Post by Rik van Kekem via Lazarus
Text (code segment) file busy
Yes, it matches.
Post by Rik van Kekem via Lazarus
The specified disk or diskette cannot be accessed.
Of course a program can generate an runtime error itself via Error(Code)
in which case the code didn't come from the OS and it might mean
something different.
Ah.

It maybe these: https://freepascal.org/docs-html/user/userap4.html

Yesterday I wrote my own Function RunTimeErrorString(I: Word): string; from that list.

begin
case I of
1: RunTimeErrorString:= 'Invalid function number'; //An invalid operating system call was attempted.
2: RunTimeErrorString:= ' File not found'; //Reported when trying to erase, rename or open a non-existent file.
3: RunTimeErrorString:= ' Path not found'; //Reported by the directory handling routines when a path does not exist or is invalid. Also reported when trying to access a non-existent file.
4: RunTimeErrorString:= ' Too many open files'; //The maximum number of files currently opened by your process has been reached. Certain operating systems limit the number of files which can be opened concurrently, and this error can occur when this limit has been reached.
5: RunTimeErrorString:= ' File access denied'; //Permission to access the file is denied. This error might be caused by one of several reasons:
...

(I can post it complete if it is of interest)
Post by Rik van Kekem via Lazarus
var
  I: Integer;
begin
  for I := 0 to 99 do
  begin
    Memo1.Lines.Add(Format('%d - %s', [I, SysErrorMessage(I)]));
  end;
:-)
Post by Rik van Kekem via Lazarus
0 - The operation completed successfully.
1 - Incorrect function.> 2 - The system cannot find the file specified.
3 - The system cannot find the path specified.
4 - The system cannot open the file.
5 - Access is denied.
...
Post by Rik van Kekem via Lazarus
99 -
0 - Success
1 - Operation not permitted
2 - No such file or directory
3 - No such process
4 - Interrupted system call
5 - I/O error
...
Post by Rik van Kekem via Lazarus
99 - Cannot assign requested address
So, because of the differences in Windows and Linux it might be best to
always show the SysErrorMessage(code) too (if it is indeed an OS error).
It will generate a much clearer message.
Yes, indeed.

Thank you!
--
Cheers / Saludos,

Carlos E. R.
(from 42.3 x86_64 "Malachite" at Telcontar)
Carlos E. R. via Lazarus
2018-05-01 10:57:28 UTC
Permalink
Post by Rik van Kekem via Lazarus
var
  I: Integer;
begin
  for I := 0 to 99 do
  begin
    Memo1.Lines.Add(Format('%d - %s', [I, SysErrorMessage(I)]));
  end;
In fact, it also prints errors beyond 100:

program errormessages;
uses
sysutils;

var
I: Integer;
begin
for I := 0 to 200 do
begin
Writeln(I, ': ', SysErrorMessage(I));
end;
end.

...
99: Cannot assign requested address
100: Network is down
101: Network is unreachable
102: Network dropped connection because of reset
103: Software caused connection abort
104: Connection reset by peer
105: No buffer space available
106: Transport endpoint is already connected
107: Transport endpoint is not connected
108: Cannot send after transport endpoint shutdown
109: Too many references: cannot splice
110: Connection timed out
111: Connection refused
112: Host is down
113: No route to host
114: Operation already in progress
115: Operation now in progress
116: Stale NFS file handle
117: Structure needs cleaning
118: Not a XENIX named type file
119: No XENIX semaphores available
120: Is a named type file
121: Remote I/O error
122: Quota exceeded
123: No medium found
124: Wrong medium type
125: Unknown Error (125)
126: Unknown Error (126)


So I do not have to check for error range validity myself. Next step
would be produce a crash and check the runtime error validity, just in
case it matches. :-)


Pity the help pages I found (like the one for ioresult) do not mention
SysErrorMessage.
--
Cheers / Saludos,

Carlos E. R.
(from 42.3 x86_64 "Malachite" at Telcontar)
Loading...