14
Pascal 4.0 User’s Guide
2
Using a Sample Program with Segmentation Violation
A segmentation violation occurs when your program tries to reference memory
outside your address space. The operating system detects this action and
generates an error message. Following is an example program,
SegViol.p
,
which contains a segmentation violation:
Compiling and Running the Program
When you compile and run the program, you receive output similar to the
following. The first line indicates the name of the offending signal—in this
case, a segmentation violation.
program SegmentationViolation;
type
Pinteger = ^integer;
procedure ErrorInHere;
var
IntVar: integer;
NullPtr: Pinteger;
begin
NullPtr := nil;
{ Next statement causes a SEGV }
IntVar := NullPtr^;
end;
procedure Call1;
procedure Call2;
begin
ErrorInHere;
end;
begin
Call2;
end;
begin
Call1;
end.
Содержание SunSoft Pascal 4.0
Страница 14: ...xiv Pascal 4 0 User s Guide ...
Страница 16: ...xvi Pascal 4 0 User s Guide ...
Страница 30: ...6 Pascal 4 0 User s Guide 1 ...
Страница 160: ...136 Pascal 4 0 User s Guide 6 ...
Страница 268: ...244 Pascal 4 0 User s Guide 11 ...
Страница 320: ...296 Pascal 4 0 User s Guide B ...
Страница 331: ...Index 307 ...
Страница 333: ......