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.
Summary of Contents for SunSoft Pascal 4.0
Page 14: ...xiv Pascal 4 0 User s Guide ...
Page 16: ...xvi Pascal 4 0 User s Guide ...
Page 30: ...6 Pascal 4 0 User s Guide 1 ...
Page 160: ...136 Pascal 4 0 User s Guide 6 ...
Page 268: ...244 Pascal 4 0 User s Guide 11 ...
Page 320: ...296 Pascal 4 0 User s Guide B ...
Page 331: ...Index 307 ...
Page 333: ......