Iwao Kimura on Wed, 28 Nov 2012 14:35:20 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: when pari_init() fail |
On Wed, Nov 28, 2012 at 05:37:28PM +0900, Iwao Kimura wrote:No, it is a bug. In pari_init_opts(), the call to
> Hi all,
>
> The following short code is compiled normaly but it fails when invoked:
> /* zzpari.c */
> #include <pari/pari.h>
>
> int
> main (void)
> {
> Â pari_init(10000, 2);
> Â return 0;
> }
> $ gcc -o zzpari-dyn zzpari.c -O3 -mtune=native -g -Wall
> -fno-strict-aliasing -fomit-frame-pointer
> Â-I /home/iwao/include -L/home/iwao/lib -Wl,-rpath "/home/iwao/lib" -lpari
> -lgmp -lm
> $ ./zzpari-dyn
> Â *** Â bug in PARI/GP (Segmentation Fault), please report.
> Â *** Â Error in the PARI system. End of program.
>
> The code is 'git pull'ed today.
>
> I found the reason why this happen by some hours investigation,
> the first argument of pari_init() is too small.
> But I wonder this behavior is intended one or not.
initprimetable() happens too soon. It shoud at least
be after init_universal_constants() so that
err_e_STACK is defined.
With that change, one get:
 ***  the PARI stack overflows !
 current stack size: 10000 (0.010 Mbytes)
 [hint] you can increase GP stack with allocatemem()
Whether this one is intended or not is another story.
 ***  Error in the PARI system. End of program.
(This is due to commit 496549f714f3).
In practice, the prime table is computed at least up to
65309, which need about 40000 bytes of stack (on 64bit).
Cheers,
Bill.