Spivoxity / obc-3

Oxford Oberon-2 compiler
38 stars 7 forks source link

Segmentation faults with large arrays #8

Closed Spivoxity closed 5 years ago

Spivoxity commented 5 years ago

Diego Sardina writes: This code with a large array (of 2^18-1 elements) leads to segmentation fault.

MODULE test2;
  VAR string: ARRAY 0FFFFFFFH OF CHAR; i: INTEGER;
BEGIN
  FOR i := 0 TO LEN(string)-1 DO END;
END test2.

Platform: Linux CentOS 7.3 x64

Spivoxity commented 5 years ago

The problem is artithmetic overflow of pointer arithmetic in gc.c(scratch_alloc).

Spivoxity commented 5 years ago

As a workaround, try allocating from the heap:

VAR string: POINTER TO ARRAY OF CHAR;
NEW(string, 0FFFFFFFFH);
Spivoxity commented 5 years ago

Fixed in 3.0.3