crash on __gmpz_init
Torbjörn Granlund
tg at gmplib.org
Mon Jan 22 14:34:21 CET 2024
Vincent Lefevre <vincent at vinc17.net> writes:
On 2024-01-22 11:02:21 +0100, Marc Glisse wrote:
> Hello,
>
> mpz_class M[LINES][COLS];
>
> you are trying to put an array with millions of elements on the stack, so
> the stack overflows. Very large arrays need to be allocated on the heap in
> C++ (new, malloc, or some wrapper like std::vector).
Note that the user has a segmentation fault in __gmpz_init for
test2_mem.c too (tc_7000x5000), which uses malloc(). See the
gdb output.
Note that there are several typos for the dimensions in the examples, so
making sense of things is pretty hard.
Seeing segfaults in mpz_init for crazy stack offsets is expected for
stack overflow, I think.
--
Torbjörn
Please encrypt, key id 0xC8601622
More information about the gmp-bugs
mailing list