]> git.ipfire.org Git - thirdparty/valgrind.git/commit
Fix segmentation violation caused by stack misalignment when vgdb use ptrace to force...
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Wed, 1 Aug 2018 17:37:13 +0000 (19:37 +0200)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Wed, 1 Aug 2018 17:37:13 +0000 (19:37 +0200)
commitc97f132676cb1e41844c622528265e06a06aedfe
tree126b1852ecd0675827253960ab970ea6b7a023bc
parent5f900edef158f39b51414f8d5f20cd99363b2c09
Fix segmentation violation caused by stack misalignment when vgdb use ptrace to force activate gdbserver

On amd64, on a big application, a vgdb call that wakes up the application
using ptrace fails unfrequently (we speak about one failure every few thousands vgdb calls).
The failure started to appear when valgrind was compiled with gcc 7.3 instead of gcc 6.4

After investigation:
* gcc 7.3 is using (more) sse instructions
* Such instructions imply to have a stack pointer aligned on 16 bytes.
* vgdb-invoker-ptrace.c 'ptrace' modification of the stack pointer was
  not respecting the amd64 ABI convention to align on 16 bytes.
  It was also not protecting the red zone (unclear if this could cause
  the problem, but in any case, this ptrace logic is similar to a
  signal handler, and cannot modify the redzone.

The fix consists in respecting the ABI.

Without the patch, segmentation violation due to an sse instruction
being executed with an address on the stack not aligned on 16 bytes,
happening something like every 5000 vgdb execution.
With the patch, 250_000 executions without problems.
coregrind/vgdb-invoker-ptrace.c