EXC_I386_INVOP in GMP 6.1.2 on OS X

mgrogue mgrogue at wi.rr.com
Sat May 25 01:32:30 UTC 2019

I d/l’d the GMP source, ran configure and make on the MacBook Pro (early 2013) with the issue.  I also have a iMac with the same version of the OS and compiler and GMP works correctly on that computer.  The software also worked correctly on this MacBook Pro with GMP 5.1.1.

There are a lot of source files in the application (hundreds) and other 3rd party libraries, but since the error implies that GMP was not compiled correctly, I would have to create a small program to reproduce the error.  if you still want me to reproduce with a small program then let me know.

Here is what I see in lldb.  You can see the instruction that it had a problem with.

Process 60112 stopped

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)

    frame #0: 0x00000001000d04f5 pfgw64`__gmpn_mul_1 + 213


->  0x1000d04f5 <+213>: mulxq  (%rsi), %r9, %rax

    0x1000d04fa <+218>: testq  %rcx, %rcx

    0x1000d04fd <+221>: jne    0x1000d0527               ; <+263>

    0x1000d04ff <+223>: movq   %r9, (%rdi)

Target 0: (pfgw64) stopped.

(lldb) up

frame #1: 0x00000001000cb5ae pfgw64`__gmpz_mul_ui + 78


->  0x1000cb5ae <+78>: movq   %rax, (%r13,%rbx,8)

    0x1000cb5b3 <+83>: cmpq   $0x1, %rax

    0x1000cb5b7 <+87>: sbbl   $-0x1, %ebx

    0x1000cb5ba <+90>: movl   %ebx, %eax

(lldb) up

frame #2: 0x00000001000937f0 pfgw64`Integer::m_mul(this=0x0000000101e02b60, n=10) at integer.cpp:33:7

   30  	{

   31  	   if(n>=0)

   32  	   {

-> 33  	      mpz_mul_ui(m_g,m_g,n);

   34  	   }

   35  	   else

   36  	   {

(lldb) p m_g

(mpz_t) $0 = {

  [0] = {

    _mp_alloc = 2

    _mp_size = 1

    _mp_d = 0x0000000101e02b90



(lldb) p n

(int32_t) $1 = 10

The output from configure is attached at the end of the e-mail.

/Users/mark/distributed/gmp-6.1.2 > uname -a
Darwin i7quad.local 18.6.0 Darwin Kernel Version 18.6.0: Tue May  7 22:54:55 PDT 2019; root:xnu-4903. x86_64

/Users/mark/distributed/gmp-6.1.2 > ./config.guess


/Users/mark/distributed/gmp-6.1.2 > ./configfsf.guess


I believe this covers everything needed for a bug report.

A separate issue is a couple of compiler warnings with GMP on that MacBook.  These appear to be unrelated to the issue I’m running into.

t-get_str.c:68:30: warning: format specifies type 'void *' but the argument has type 'char *' [-Wformat-pedantic]

      printf ("  got  %p\n", ret);

                      ~~     ^~~


t-get_str.c:69:30: warning: format specifies type 'void *' but the argument has type 'const char *' [-Wformat-pedantic]

      printf ("  want %p\n", want);

                      ~~     ^~~~


2 warnings generated.

repl-vsnprintf.c:396:30: warning: ISO C requires a translation unit to contain at least one declaration [-Wempty-translation-unit]

#endif /* ! HAVE_VSNPRINTF */


1 warning generated.

More information about the gmp-bugs mailing list