> < ^ Date: Fri, 06 Nov 1992 07:08:53 +0100
> < ^ From: Werner Nickel <nickel@mathematik.tu-darmstadt.de >
> ^ Subject: Corrupted heap.

A while ago there was a bit of discussion about GAP's Error message

gap: panic 'SyGetmem' detected corrupted heap!

Martin Schoenert explained that GAP basically produces this error
message if it detects that some subroutine interferes with GAP's
storage management. I just got this error message from GAP. In
trying to understand why, I discovered that there is an implicit
assumption made about sbrk() in the routine SyGetmem(). This
assumption does not seem to be satisfied in SunOS 4.1.1.

SyGetmem() contains the following line of code:

if ( ret != (char*)-1 )  syHighmem = ret + size;

This line of code assumes that the new break value (assigned to
'syHighmem') is equal to the old break value (stored in 'ret')
plus 'size' (the argument to SyGetmem()). That means it assumes
that the alignment of 'size' is consistent with the alignment that
sbrk() enforces.
But on SunOS 4.1.1 it seems to be the case that sbrk() aligns the
additional memory to a multiple of 8 while 'size' is only
guaranteed to be divisible by 4. Therefore in the next call of
SyGetmem() there can be a discrepancy of 4 bytes between syHighmem
and the value returned by sbrk() in which case GAP believes that
the heap is corrupted. This was precisely the reason why GAP gave me
the error message above.

My suggestion is to remove this implicit assumption by replacing that
line of code by the following:

if ( ret != (char*)-1 )  syHighmem = sbrk(0);

Werner Nickel
Mathematics Research Section
Australian National University

> < [top]