From: Simon Marchi <simon.marchi@ericsson.com>
To: Pedro Alves <palves@redhat.com>, <gdb@sourceware.org>
Cc: Yao Qi <qiyaoltc@gmail.com>
Subject: Re: Debugging return.exp on ARM
Date: Fri, 27 May 2016 13:35:00 -0000 [thread overview]
Message-ID: <57484D29.4020800@ericsson.com> (raw)
In-Reply-To: <a8700f42-7139-bf7e-7ad9-48a7e47d5863@redhat.com>
On 16-05-26 03:11 PM, Pedro Alves wrote:
Thanks for the suggestions.
> - I'd suspect something odd with caches / barriers too.
> Did you try sprinkling in memory barrier instructions, and
> see whether it makes a difference?
I tried to put some dmb a bit everywhere, it didn't help.
> - I'd also try "si" + "info regs" instead of "next" after the return,
> and see if a register with a bad value pops up always at some
> specific instruction.
Good point.
If I replace next with si, only the vmov.f64 d7, d0 gets executed. So if everything
goes well, I should have the "right" value in both d0 and d7. I made a more
focused reproducer, see below.
> - I'd try to see if pinning the thread to a core makes a difference.
Indeed, pinning GDB to a single CPU makes it work (as in the result is right) every time.
As far as I can tell, pinning the inferior has no effect (I am not sure i worked, but I
used "set exec-wrapper taskset 0xffffffff" to reset the affinity).
> - Might help to show the kernel version.
ODroid: Linux odroid 3.10.96+ #5 SMP PREEMPT Thu May 26 15:03:58 EDT 2016 armv7l armv7l armv7l GNU/Linux
Firefly: Linux firefly 3.10.0 #40 SMP PREEMPT Tue Jan 27 16:12:04 CST 2015 armv7l armv7l armv7l GNU/Linux
I also reproduced it on my Rasp Pi 2, which has:
Linux alarmpi 4.4.8-2-ARCH #1 SMP Tue Apr 26 19:14:58 MDT 2016 armv7l GNU/Linux
So here's another case that reproduces the problem, but without a memory read, so
it isolates the problem a bit more. It verifies whether the thread sees our register
write or not.
test.S:
.global _start
_start:
vldr.64 d0, constante
vldr.64 d1, constante
break_here:
vcmp.f64 d0, d1
vmrs APSR_nzcv, fpscr
# Exit code
moveq r0, #1
movne r0, #0
# Exit syscall
mov r7, #1
svc 0
.align 8
constante:
.word 0xc8b43958
.word 0x40594676
Built with:
$ gcc -g3 -O0 -o test test.S -nostdlib
And the gdb script test.gdb:
file test
b break_here
run
p $d0 = 4.0
c
The test is ran with
$ ./gdb -nx -x test.gdb -batch
The test loads the same constant in d0 and d1. It then does a comparison between
them and exits with 1 (failure) if they are the same, 0 (success) if they are different.
The GDB script breaks at "break_here", tries to change the value of d0 to some other
constant (4.0) and lets the program continue and exit. If our register write succeeded,
the program should exit with 0 (values are different). If our register write failed, the
program will exit with 1 (values are still the same).
The result is that I randomly see both cases, hinting that the race is really between the
register write through ptrace and the kernel restoring the thread's vfp registers. Again,
pinning GDB to a single code seems to hide/bypass the bug.
Simon
next prev parent reply other threads:[~2016-05-27 13:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-26 15:15 Simon Marchi
2016-05-26 19:11 ` Pedro Alves
2016-05-27 13:35 ` Simon Marchi [this message]
2016-06-01 15:17 ` Yao Qi
2016-06-01 15:22 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=57484D29.4020800@ericsson.com \
--to=simon.marchi@ericsson.com \
--cc=gdb@sourceware.org \
--cc=palves@redhat.com \
--cc=qiyaoltc@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox