[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bignum branch

From: Andy Moreton
Subject: Re: bignum branch
Date: Sun, 12 Aug 2018 20:44:03 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.50 (windows-nt)

On Sun 12 Aug 2018, Eli Zaretskii wrote:

>> From: Andy Moreton <address@hidden>
>> Date: Sat, 11 Aug 2018 23:15:28 +0100
>> As Tom has completed merging to master, I have switched to the master
>> branch and rebuilt from a clean tree (after "git clean -Xdf").
>> Stepping through the code in gdb, I see:
>> (gdb) stepi
>> 0x000000040016ebcb      1845        __gmp_result =  mpn_popcount 
>> (__gmp_u->_mp_d, __gmp_usize);
>> (gdb)
>> 0x000000046ace5dc0 in ?? ()
>> (gdb)
>> Thread 1 received signal SIGSEGV, Segmentation fault.
>> 0x000000046ace5dc0 in ?? ()
> I don't see this here, with mingw.org's GMP library.
> If you step through the code after typing
>   (gdb) set debugexceptions on
> what Windows exception is reported that leads to this SIGSEGV?

(gdb) n
gdb: Target exception EXCEPTION_SINGLE_STEP at 0x40016c2ee
gdb: Target exception EXCEPTION_SINGLE_STEP at 0x4000e9446
gdb: Target exception EXCEPTION_BREAKPOINT at 0x40016c2f3
gdb: Target exception EXCEPTION_SINGLE_STEP at 0x40016c2f6
gdb: Target exception EXCEPTION_SINGLE_STEP at 0x40016c2f8
gdb: Target exception EXCEPTION_SINGLE_STEP at 0x40016c2fa
3335            return make_fixnum (mpz_popcount (XBIGNUM (value)->value));
(gdb) s
__gmpz_popcount (__gmp_u=0x400c0a768 <dumped_data+4928520>) at 
1844      if (__GMP_LIKELY (__gmp_usize > 0))
[New Thread 836.0x888]
gdb: Target exception EXCEPTION_SINGLE_STEP at 0x40016c300
1845        __gmp_result =  mpn_popcount (__gmp_u->_mp_d, __gmp_usize);
gdb: Target exception EXCEPTION_SINGLE_STEP at 0x40016c304
gdb: Target exception EXCEPTION_SINGLE_STEP at 0x46ace5dc0
0x000000046ace5dc0 in ?? ()
Cannot find bounds of current function
(gdb) stepi
gdb: Target exception EXCEPTION_ACCESS_VIOLATION at 0x46ace5dc0

Thread 1 received signal SIGSEGV, Segmentation fault.
0x000000046ace5dc0 in ?? ()

> Also, could you try compiling and running the small program attached
> below.  It is a slightly modified code of Flogcount, and I'm curious
> to know whether it crashes in the same way if you compile it like the
> crashing Emacs: with the -Og switch and with gmp.h set up for static
> linking.  (It didn't crash for me here.)  Also, do you see there the
> same call to __imp___gmpn_popcount as in the Emacs case.

I don't see a crash. Your program only accepts non-negative numbers that
are small enough to use only a single limb, so may not be representative
as a cut down test case.

I saved the code in foo.c and built with "gcc -Og -o foo.exe foo.c -lgmp".
Dumping in gdb, I see the same call to __imp___gmpn_popcount:

(gdb) disas main
Dump of assembler code for function main:
   0x0000000000401560 <+0>:     push   %rsi
   0x0000000000401561 <+1>:     push   %rbx
   0x0000000000401562 <+2>:     sub    $0x48,%rsp
   0x0000000000401566 <+6>:     mov    %ecx,%ebx
   0x0000000000401568 <+8>:     mov    %rdx,%rsi
   0x000000000040156b <+11>:    callq  0x4016f0 <__main>
   0x0000000000401570 <+16>:    cmp    $0x1,%ebx
   0x0000000000401573 <+19>:    jg     0x4015b4 <main+84>
   0x0000000000401575 <+21>:    mov    $0x2a,%esi
   0x000000000040157a <+26>:    lea    0x30(%rsp),%rbx
   0x000000000040157f <+31>:    mov    %rbx,%rcx
   0x0000000000401582 <+34>:    callq  0x401640 <__gmpz_init>
   0x0000000000401587 <+39>:    mov    %esi,%r8d
   0x000000000040158a <+42>:    mov    %rbx,%rdx
   0x000000000040158d <+45>:    mov    %rbx,%rcx
   0x0000000000401590 <+48>:    callq  0x401650 <__gmpz_add_ui>
   0x0000000000401595 <+53>:    mov    0x34(%rsp),%edx
   0x0000000000401599 <+57>:    test   %edx,%edx
   0x000000000040159b <+59>:    js     0x4015c8 <main+104>
   0x000000000040159d <+61>:    jle    0x4015c1 <main+97>
   0x000000000040159f <+63>:    mov    0x38(%rsp),%rcx
   0x00000000004015a4 <+68>:    callq  0x408220 <__imp___gmpn_popcount>
   0x00000000004015a9 <+73>:    mov    %eax,%ebx
   0x00000000004015ab <+75>:    mov    %ebx,%eax
   0x00000000004015ad <+77>:    add    $0x48,%rsp
   0x00000000004015b1 <+81>:    pop    %rbx
   0x00000000004015b2 <+82>:    pop    %rsi
   0x00000000004015b3 <+83>:    retq
   0x00000000004015b4 <+84>:    mov    0x8(%rsi),%rcx
   0x00000000004015b8 <+88>:    callq  0x402c68 <atoi>
   0x00000000004015bd <+93>:    mov    %eax,%esi
   0x00000000004015bf <+95>:    jmp    0x40157a <main+26>
   0x00000000004015c1 <+97>:    mov    $0x0,%eax
   0x00000000004015c6 <+102>:   jmp    0x4015a9 <main+73>
   0x00000000004015c8 <+104>:   lea    0x20(%rsp),%rbx
   0x00000000004015cd <+109>:   mov    %rbx,%rcx
   0x00000000004015d0 <+112>:   callq  0x401640 <__gmpz_init>
   0x00000000004015d5 <+117>:   lea    0x30(%rsp),%rdx
   0x00000000004015da <+122>:   mov    %rbx,%rcx
   0x00000000004015dd <+125>:   callq  0x401638 <__gmpz_set>
   0x00000000004015e2 <+130>:   mov    0x24(%rsp),%eax
   0x00000000004015e6 <+134>:   neg    %eax
   0x00000000004015e8 <+136>:   mov    %eax,0x24(%rsp)
   0x00000000004015ec <+140>:   mov    $0x1,%r8d
   0x00000000004015f2 <+146>:   mov    %rbx,%rdx
   0x00000000004015f5 <+149>:   mov    %rbx,%rcx
   0x00000000004015f8 <+152>:   callq  0x401630 <__gmpz_sub_ui>
   0x00000000004015fd <+157>:   mov    0x24(%rsp),%edx
   0x0000000000401601 <+161>:   test   %edx,%edx
   0x0000000000401603 <+163>:   js     0x401626 <main+198>
   0x0000000000401605 <+165>:   mov    $0x0,%eax
   0x000000000040160a <+170>:   test   %edx,%edx
   0x000000000040160c <+172>:   jle    0x401618 <main+184>
   0x000000000040160e <+174>:   mov    0x28(%rsp),%rcx
   0x0000000000401613 <+179>:   callq  0x408220 <__imp___gmpn_popcount>
   0x0000000000401618 <+184>:   mov    %eax,%ebx
   0x000000000040161a <+186>:   lea    0x20(%rsp),%rcx
   0x000000000040161f <+191>:   callq  0x401648 <__gmpz_clear>
   0x0000000000401624 <+196>:   jmp    0x4015ab <main+75>
   0x0000000000401626 <+198>:   mov    $0xffffffff,%eax
   0x000000000040162b <+203>:   jmp    0x40160a <main+170>
   0x000000000040162d <+205>:   nop
   0x000000000040162e <+206>:   nop
   0x000000000040162f <+207>:   nop
End of assembler dump.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]