Applications generated by Free Pascal might generate run-time errors when certain abnormal conditions are detected in the application. This appendix lists the possible run-time errors and gives information on why they might be produced.
An invalid operating system call was attempted.
Reported when trying to erase, rename or open a non-existent file.
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.
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.
Permission to access the file is denied. This error might be caused by one of several reasons:
Trying to open for writing a file which is read-only, or which is actually a directory.
File is currently locked or used by another process.
Trying to create a new file, or directory while a file or directory of the same name already exists.
Trying to read from a file which was opened in write-only mode.
Trying to write from a file which was opened in read-only mode.
Trying to remove a directory or file while it is not possible.
No permission to access the file or directory.
If this happens, the file variable you are using is trashed; it indicates that your memory is corrupted.
Reported when a reset or rewrite is called with an invalid FileMode value.
The number given to the Getdir or ChDir function specifies a non-existent disk.
Reported when trying to remove the currently active directory.
You cannot rename a file such that it would end up on another disk or partition.
An error occurred when reading from disk. Typically happens when you try to read past the end of a file.
Reported when the disk is full, and you’re trying to write to it.
This is reported by Reset, Rewrite, Append, Rename and Erase, if you call them with an unassigned file as a parameter.
Reported by the following functions : Close, Read, Write, Seek, EOf, FilePos, FileSize, Flush, BlockRead, and BlockWrite if the file is not open.
Reported by Read, BlockRead, Eof, Eoln, SeekEof or SeekEoln if the file is not opened with Reset.
Reported by write if a text file isn’t opened with Rewrite.
Reported when a non-numeric value is read from a text file, and a numeric value was expected.
Reported when a text representation of an enumerated constant cannot be created in a call to str or write(ln).
(Critical error)
(Critical error)
(Critical error)
(Critical error)
(Critical error)
(Critical error)
(Critical error)
(Critical error)
(Critical error)
(Critical error)
(Critical error)
The application attempted to divide a number by zero.
If you compiled your program with range checking on, then you can get this error in the following cases:
The stack has grown beyond its maximum size (in which case the size of local variables should be reduced to avoid this error), or the stack has become corrupt. This error is only reported when stack checking is enabled.
The heap has grown beyond its boundaries. This is caused when trying to allocate memory explicitly with New, GetMem or ReallocMem, or when a class or object instance is created and no memory is left. Please note that, by default, Free Pascal provides a growing heap, i.e. the heap will try to allocate more memory if needed. However, if the heap has reached the maximum size allowed by the operating system or hardware, then you will get this error.
You will get this in several cases:
if you call Dispose or Freemem with an invalid pointer
in case New or GetMem is called, and there is no more memory available. The behavior in this case depends on the setting of ReturnNilIfGrowHeapFails. If it is True, then Nil is returned. if False, then runerror 204 is raised.
You are trying to use or produce real numbers that are too large.
You are trying to use or produce real numbers that are too small.
Can occur if you try to calculate the square root or logarithm of a negative number.
When compiled with range checking on, a program will report this error if you call a virtual method without having called its object’s constructor.
Your program tried to execute an abstract virtual method. Abstract methods should be overridden, and the overriding method should be called.
This occurs when an invalid type is registered in the objects unit.
You are trying to access a collection item with an invalid index (objects unit).
The collection has reached its maximal size, and you are trying to add another element (objects unit).
This error is reported when the result of an arithmetic operation is outside of its supported range. Contrary to Turbo Pascal, this error is only reported for 32-bit or 64-bit arithmetic overflows. This is due to the fact that everything is converted to 32-bit or 64-bit before doing the actual arithmetic operation.
The application tried to access invalid memory space. This can be caused by several problems:
An exception occurred, and there was no exception handler present. The sysutils unit installs a default exception handler which catches all exceptions and exits gracefully.
Error 218 occurs when an invalid value was specified to a system call, for instance when specifying a negative value to a seek() call.
Thrown when an invalid typecast is attempted on a class using the as operator. This error is also thrown when an object or class is typecast to an invalid class or object and a virtual method of that class or object is called. This last error is only detected if the -CR compiler option is used.
No dispatch method to call from variant.
The variant array creation failed. Usually when there is not enough memory.
This error occurs when a variant array operation is attempted on a variant which is not an array.
This error occurs when a variant array index is out of bounds.
An assertion failed, and no AssertErrorProc procedural variable was installed.
This error occurs is a safecall check fails, and no handler routine is available.
This error occurs when the exception object is retrieved and none is available.
Thread management relies on a separate driver on some operating systems (notably, Unixes). The unit with this driver needs to be specified on the uses clause of the program, preferably as the first unit (cthreads on unix).
Unicode string management relies on a separate driver. On some operating systems (notably, Unixes) this driver must be enabled specificly. This can be done by using the cwstring unit which uses libc, or the fpwidestring unit (which is a native pascal widestring manager).