From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Andy Moreton Newsgroups: gmane.emacs.devel Subject: Re: bignum branch Date: Sun, 12 Aug 2018 20:44:03 +0100 Message-ID: <86ftzjs73w.fsf@gmail.com> References: <87o9fbbw1t.fsf@tromey.com> <86lg9gl7vy.fsf@gmail.com> <87tvo4i9em.fsf@tromey.com> <86k1ozl0yd.fsf@gmail.com> <83in4iojva.fsf@gnu.org> <86bmaasm39.fsf@gmail.com> <83a7puo8oq.fsf@gnu.org> <83zhxummef.fsf@gnu.org> <83lg9em1v6.fsf@gnu.org> <86r2j5q67t.fsf@gmail.com> <83r2j4lvyo.fsf@gnu.org> <86va8gj12l.fsf@gmail.com> <83k1owlscr.fsf@gnu.org> <86mutsiy80.fsf@gmail.com> <83eff4lqon.fsf@gnu.org> <86eff4ixcj.fsf@gmail.com> <83a7pslnzz.fsf@gnu.org> <86eff4turj.fsf@gmail.com> <83y3dbju00.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1534102944 11237 195.159.176.226 (12 Aug 2018 19:42:24 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 12 Aug 2018 19:42:24 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.50 (windows-nt) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Aug 12 21:42:20 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fowFm-0002oR-Rh for ged-emacs-devel@m.gmane.org; Sun, 12 Aug 2018 21:42:19 +0200 Original-Received: from localhost ([::1]:36169 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fowHr-0006Pt-N7 for ged-emacs-devel@m.gmane.org; Sun, 12 Aug 2018 15:44:27 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55455) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fowHh-0006Nb-O3 for emacs-devel@gnu.org; Sun, 12 Aug 2018 15:44:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fowHe-0005UC-KE for emacs-devel@gnu.org; Sun, 12 Aug 2018 15:44:17 -0400 Original-Received: from [195.159.176.226] (port=33687 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fowHe-0005Ti-9J for emacs-devel@gnu.org; Sun, 12 Aug 2018 15:44:14 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1fowFU-0002Wj-FU for emacs-devel@gnu.org; Sun, 12 Aug 2018 21:42:00 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 137 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:VCs85RSNvFmGOVe4QCbvBIQdAHE= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:228457 Archived-At: On Sun 12 Aug 2018, Eli Zaretskii wrote: >> From: Andy Moreton >> 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 ) at C:/msys64/mingw64/include/gmp.h:1844 1844 if (__GMP_LIKELY (__gmp_usize > 0)) (gdb) [New Thread 836.0x888] gdb: Target exception EXCEPTION_SINGLE_STEP at 0x40016c300 1845 __gmp_result = mpn_popcount (__gmp_u->_mp_d, __gmp_usize); (gdb) gdb: Target exception EXCEPTION_SINGLE_STEP at 0x40016c304 gdb: Target exception EXCEPTION_SINGLE_STEP at 0x46ace5dc0 0x000000046ace5dc0 in ?? () (gdb) 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 ?? () (gdb) > 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 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 0x000000000040159d <+61>: jle 0x4015c1 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 0x00000000004015bd <+93>: mov %eax,%esi 0x00000000004015bf <+95>: jmp 0x40157a 0x00000000004015c1 <+97>: mov $0x0,%eax 0x00000000004015c6 <+102>: jmp 0x4015a9 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 0x0000000000401605 <+165>: mov $0x0,%eax 0x000000000040160a <+170>: test %edx,%edx 0x000000000040160c <+172>: jle 0x401618 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 0x0000000000401626 <+198>: mov $0xffffffff,%eax 0x000000000040162b <+203>: jmp 0x40160a 0x000000000040162d <+205>: nop 0x000000000040162e <+206>: nop 0x000000000040162f <+207>: nop End of assembler dump. (gdb)