Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: Yao Qi <qiyaoltc@gmail.com>
Cc: Phil Muldoon <pmuldoon@redhat.com>,
	John Baldwin <jhb@freebsd.org>,
	       gdb-patches@sourceware.org
Subject: Re: [PATCH 1/2] Include the fs_base and gs_base registers in amd64 target descriptions.
Date: Wed, 12 Jul 2017 13:51:00 -0000	[thread overview]
Message-ID: <fc14e67981253db1479231812494f90b@polymtl.ca> (raw)
In-Reply-To: <CAH=s-PPM7u=f=_4k+=wLvv4z822VJRqbkxrsSv9C0eKqX-tMCA@mail.gmail.com>

On 2017-07-12 15:02, Yao Qi wrote:
> On Wed, Jul 12, 2017 at 1:16 PM, Phil Muldoon <pmuldoon@redhat.com> 
> wrote:
>> 
>> Does anyone else see this?
>> 
> 
> I don't see the issue you posted here, but there are
> some regressions shown in buildbot.
> https://sourceware.org/ml/gdb-testers/2017-q3/msg00370.html
> 
> John, could you take a look?

I looked around, I don't know exactly what's wrong but I might have some 
pointers.

 From what I understand, tdesc_use_registers adds the registers listed in 
the target description to a hash table, and then removes some of those 
same registers that are also specified by the architecture, so it's left 
with the registers for which we need to assign a number.  The hash table 
hash the pointer itself, it does not look at what it points to.

I added some prints where we add and remove the registers from the htab. 
  For rax, it looks good:

ADDING 0x237a510 rax
REMOVING 0x237a510 rax

We add and remov the same pointer.  For fs_base, the pointers are 
different:

ADDING 0x237d840 fs_base
REMOVING 0x23a5d70 fs_base

It suggests that something is wrong here, I would expect those two 
pointers to be equal.  I don't know enough about how the reg objects are 
created to know why it this happens.

Despite that, a segfault happens when we are calling htab_remove_elt 
with an element that does not exist in the hash table.  This case should 
be handled correctly, since this function allows that:

707 /* This function deletes an element with the given value from hash
708    table (the hash is computed from the element).  If there is no 
matching
709    element in the hash table, this function does nothing.  */
710
711 void
712 htab_remove_elt (htab_t htab, PTR element)

The problem seems to be in htab_remove_elt_with_hash:

727   slot = htab_find_slot_with_hash (htab, element, hash, NO_INSERT);
728   if (*slot == HTAB_EMPTY_ENTRY)
729     return;

htab_find_slot_with_hash can return NULL if you pass NO_INSERT and the 
element is non-existent.  So it looks like it's missing a slot != NULL 
on line 728.

Hope that helps.

Simon


  parent reply	other threads:[~2017-07-12 13:51 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-27 22:50 [PATCH 0/2] Support fs_base and gs_base for native FreeBSD/amd64 John Baldwin
2017-06-27 22:51 ` [PATCH 2/2] Support the fs_base and gs_base registers on FreeBSD/amd64 native processes John Baldwin
2017-07-11  8:09   ` Yao Qi
2017-06-27 22:51 ` [PATCH 1/2] Include the fs_base and gs_base registers in amd64 target descriptions John Baldwin
2017-07-11  8:03   ` Yao Qi
2017-07-11 16:26     ` John Baldwin
2017-07-12 12:16     ` Phil Muldoon
     [not found]       ` <CAH=s-PPM7u=f=_4k+=wLvv4z822VJRqbkxrsSv9C0eKqX-tMCA@mail.gmail.com>
2017-07-12 13:51         ` Simon Marchi [this message]
2017-07-12 20:03           ` John Baldwin
2017-07-13 16:55             ` Yao Qi
2017-07-13 17:04               ` John Baldwin
2017-07-13 18:40               ` Pedro Alves
2017-07-13 19:59                 ` Pedro Alves
2017-07-12 16:23         ` Keith Seitz
2017-07-11  7:49 ` [PATCH 0/2] Support fs_base and gs_base for native FreeBSD/amd64 Yao Qi
2017-07-11 16:26   ` John Baldwin

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=fc14e67981253db1479231812494f90b@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=jhb@freebsd.org \
    --cc=pmuldoon@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