Branch: Tag:

2016-05-29

2016-05-29 12:48:51 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Gmp.mpz: Restored the 1GB memory cut off in pow().

Gmp does NOT handle out of memory gracefully (GNU MP 6.1.0 manual):

There's currently no defined way for the allocation functions to
recover from an error such as out of memory, they must terminate
program execution. A longjmp or throwing a C++ exception will have
undefined results. This may change in the future.

Fixes multiple testsuite failures.

1961:    exponent=mpz_get_ui(mi);    }    +  /* Cut off at 1GB. */ +  size = mpz_size(THIS); +  if (INT_TYPE_MUL_OVERFLOW(exponent, size) || +  size * exponent > (INT_TYPE)(0x40000000/sizeof(mp_limb_t))) { +  if(mpz_cmp_si(THIS, -1)<0 || mpz_cmp_si(THIS, 1)>0) +  SIMPLE_ARG_ERROR ("pow", 1, "Exponent too large."); +  } +     res = fast_clone_object(THIS_PROGRAM);    mpz_pow_ui(OBTOMPZ(res), THIS, exponent);    pop_n_elems(args);