(expt 2 #large) gives different results/aborts

Hi newbie here,

I was playing around with racket and tried:
(Every next large number has the last digit removed from the previous one)

(expt 2 1234567890123456789)
ash: out of memory [,bt for context]

then

> (expt 2 123456789012345678)
nonrecoverable invalid memory reference
Aborted

> (expt 2 12345678901234567)
nonrecoverable invalid memory reference
Aborted

then

type o> (expt 2 1234567890123456)
out of memory
Aborted

> (expt 2 123456789012345)
out of memory
Aborted

> (expt 2 12345678901234)
out of memory
Aborted

> (expt 2 1234567890123)
out of memory
Aborted

>  (expt 2 123456789012)
out of memory
Aborted

then

> (expt 2 12345678901)

This last one gets a calculated result.

I'm just curious, there is no reason for me to use this, but I would like to know why the first one and largest number isn't aborted and why the ones that are aborted have two different reasons for the abort, namely "nonrecoverable invalid memory reference" and "out of memory".

I ran this on 8.6 and 8.6.0.13 with the same result.

Those are really all bugs, but especially the first 3. It would be nice to recover better from the others but that's harder. Fundamentally they're all trying to allocate far more memory than is available and crashing.

If you're interested in the code involved, it starts here:

For the very first one, it correctly notices that left-shift by a bignum is never going to work and produces a sensible error message. It would be good to do that more often.