macOS Catalina: FAIL: t-powm

Torbjörn Granlund tg at gmplib.org
Fri Nov 8 13:35:12 UTC 2019


Jack Howarth <howarth.mailing.lists at gmail.com> writes:

  FYI, I reported this issue to Apple via radar and their response was...

  Engineering has provided the following information regarding this issue:
  It sounds like gmp has a memory corruption issue which -fstack-check has
  uncovered.  We suggest filing a bug with the developers of gmp.

  So they believe clang is accurately detecting a bug in gmp. A back trace of
  the failure shows...

  bash-3.2# lldb ./t-powm
  lldb ./t-powm
  (lldb) target create "./t-powm"
  Current executable set to './t-powm' (x86_64).
  (lldb) r
  Process 39643 launched:
  '/Users/howarth/gmp_regression/default_build/t-powm' (x86_64)
  Process 39643 stopped
  * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS
  (code=EXC_I386_GPFLT)
      frame #0: 0x00007fff71afc386
  libdyld.dylib`stack_not_16_byte_aligned_error
  libdyld.dylib`stack_not_16_byte_aligned_error:
  ->  0x7fff71afc386 <+0>: movdqa %xmm0, (%rsp)
      0x7fff71afc38b <+5>: int3
      0x7fff71afc38c <+6>: nop
      0x7fff71afc38d <+7>: nop
  Target 0: (t-powm) stopped.
  (lldb) bt
  * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS
  (code=EXC_I386_GPFLT)
    * frame #0: 0x00007fff71afc386
  libdyld.dylib`stack_not_16_byte_aligned_error

  I am attaching the test case I created for them. Note that the failure can
  be triggered with only the t-powm executable built using the default stack
  checking so the problem seems to lie there and not in the gmp shared
  libraries.

I cannot repro on a Intel broadwell Mac Air laptop.

Can you help read the above output?  In what GMP function does the
poorly aligned stack occur?

If it's in mpn_powm, I cannot see how it could be GMP's fault as that
function is in C and never called by our asm.  Thus compiler error.

In a leaf (asm) function, stack alignment is not relevant unless
instructions requiring a certain alignment are used.

The only scenario which I can see where this would be a GMP bug is if an
asm GMP function made a function call without ensuring proper alignment.
But GMP very rarely make such calls; in fact I can only think of a few
places where that is done.

-- 
Torbjörn
Please encrypt, key id 0xC8601622


More information about the gmp-bugs mailing list