[GAP] Effect of using malloc for temporary allocations in GAP

Dmitrii Pasechnik dmitrii.pasechnik at cs.ox.ac.uk
Mon Jan 2 16:18:27 GMT 2017


Dear all,
On Mon, Jan 02, 2017 at 03:07:34PM +0100, Max Horn wrote:
> > On 02 Jan 2017, at 15:01, Dmitrii Pasechnik <Dmitrii.Pasechnik at cs.ox.ac.uk> wrote:
> > I would like to point out that GMP allows one to specify her/his own
> > memory allocator: https://gmplib.org/manual/Custom-Allocation.html
> > (I'm surprised that GAP does not use it, or does it?)
> 
> GAP cannot use these hooks, because the GAP GC is a moving GC.

Well, these hooks allow one to bundle on a custom malloc with address space
protected from GC. There is probably quite a big choice of custom
mallocs to pick, and very small, or none, changes to the GC needed...

> That means that
> it could happen that, after making an allocating, the actual location of
> an object (say, the inputs to the GMP function currently running) move. Since
> GMP is not aware of this, and there is no way to teach it about this (other than
> modifying its code, of course), a crash and/or corrupt data would result.

Are you talking about multithreading?
Unless GMP uses absolute address arithmetic, and assuming GC knows its
pointers, GMP can be paused, the pointers rewritten by GC as needed,
and then resumed.

[...]

Best,
Dima



More information about the Gap mailing list