On 15 Apr 2014, at 18:14, Bill Allombert <Bill.Allombert@math.u-bordeaux.fr> wrote:

On Sat, Apr 05, 2014 at 08:22:13PM +0200, Xavier Roblot wrote:

On 05 Apr 2014, at 16:57, Bill Allombert <Bill.Allombert@math.u-bordeaux.fr> wrote:

On Sat, Apr 05, 2014 at 01:20:02PM +0200, Xavier Roblot wrote:
commit 8bacf11ac11df738533edb64f8a8f040468b581f
Author: Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>
Date:   Mon Mar 19 19:05:29 2012 +0100

 Replace pari_init_stack by paristack_alloc/paristack_resize.


For information, here is GP header:

GP/PARI CALCULATOR Version 2.8.0 (development    16306-3443337)
                                      i386 running darwin (x86-64/GMP-5.1.2 kernel) 64-bit version
                         compiled: Apr  5 2014, Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
                                                       threading engine: pthread
                                             (readline v6.2 enabled, extended help enabled)

Also, if I recompile without threads (threading engine: single), the problem disappears…

Could you find out where the segfault happens using a debugger ?

Unfortunately, the bug disappears when I compile gp in debugging mode…

So compile gp in optimised mode but set CC_FLAVOR to -g.

OK, it worked. Below is what I got.

Xavier

(20:20) gp > setrand(1);sbnf=bnfcompress(bnfinit(x^3-x^2-14*x-1))
Process 93748 stopped
* thread #1: tid = 0x24b3ef, 0x00000001005211d9 libpari-gmp-tls-2.8.dylib`getrand + 601 at random.c:106, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
   frame #0: 0x00000001005211d9 libpari-gmp-tls-2.8.dylib`getrand + 601 at random.c:106
  103    if (xorgen_i < 0) init_xor4096i(1);
  104 
  105    x = cgetg(r+2 + 1, t_VECSMALL); xd = x+1;
-> 106    for (i = 0; i < r; i++) xd[i] = state[i];
  107    xd[i++] = xorgen_i;
  108    xd[i++] = xorgen_w;
  109    return x;

Hello Xavier,
Could you tell me what is the value of i ?

It’s zero, see below. Note that there seems to be a problem with r...

Xavier


Process 13568 stopped
* thread #1: tid = 0x5b1dd, 0x000000010052db49 libpari-gmp-tls-2.8.dylib`getrand + 601 at random.c:106, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
    frame #0: 0x000000010052db49 libpari-gmp-tls-2.8.dylib`getrand + 601 at random.c:106
   103   if (xorgen_i < 0) init_xor4096i(1);
   104 
   105   x = cgetg(r+2 + 1, t_VECSMALL); xd = x+1;
-> 106   for (i = 0; i < r; i++) xd[i] = state[i];
   107   xd[i++] = xorgen_i;
   108   xd[i++] = xorgen_w;
   109   return x;
(lldb) p i
(long) $0 = 0
(lldb) p r
error: use of undeclared identifier 'r'
error: 1 errors parsing expression