From: Simon Marchi <simon.marchi@polymtl.ca>
To: Pedro Alves <palves@redhat.com>
Cc: Simon Marchi <simon.marchi@ericsson.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 0/3] Create arch_lwp_info class hierarchy
Date: Wed, 16 Aug 2017 18:44:00 -0000 [thread overview]
Message-ID: <d5021e467857df4227744e5c15e95c48@polymtl.ca> (raw)
In-Reply-To: <fce4edb6-c6ec-7eaa-4cad-1fa5f290ff27@redhat.com>
On 2017-08-14 13:53, Pedro Alves wrote:
> On 08/12/2017 12:29 PM, Simon Marchi wrote:
>
>> But then I realized that I forgot to include the header for s390, and
>> the compiler (when building for a s390 host) didn't warn me. This is
>> dangerous and fragile since we end up with two definitions of
>> arch_lwp_info (the s390 one and that fallback one), and nothing to
>> warn
>> about it.
>
> Not sure whether that's really such a bad problem. It seems like the
> sort of thing that'd crash quite visibly/quickly if you actually try to
> run the resulting binary. It's not like we're adding ports
> every day. :-)
How would it crash visibly? I thought it would most likely crash or
corrupt memory seemingly randomly. That's irrelevant because of you
suggestion below, but I'm asking just for the sake of the discussion.
>> So I changed it to listing explicitly the architectures that
>> don't defined their own arch_lwp_info:
>>
>> ...
>> #elif defined __alpha__ || defined __powerpc__ || ...
>> /* Define a dummy arch_lwp_info for arches that don't define one. */
>> struct arch_lwp_info {};
>> #else
>> # error "Missing arch-specific include."
>> #endif
>>
>> That would work, but requires listing all the arches that need the
>> fallback definition of arch_lwp_info, so it gets pretty ugly.
>>
>> Any idea to make this simple but safe? Otherwise, I'll just go with
>> the
>> current version of the patch.
>
> There's a 3rd, much simpler option.
>
> The problem we ran into is one of blurred division of responsibility:
> the
> arch-specific code is responsible for allocating the arch-specific
> arch_lwp_info, which it must be, because it's not possible to allocate
> an
> incomplete type (must know its size), but we free the object in common
> code,
> where the type is opaque.
>
> We can solve the original xfree poisoning problem by simply making the
> arch-specific code responsible for releasing arch_lwp_info too, where
> the
> type is known, just like it is responsible for allocating it.
>
> See below a proof of concept doing that for the x86 port. Making other
> archs do the same should be trivial. Using new/delete/cdtors/in-class
> initialization for arch_lwp_info would be a separate, orthogonal change
> (and so would class-ification of linux_nat_new_thread,
> linux_target_ops,
> etc.).
Yes, that makes sense. I'll try that. Thanks for the prototype.
Simon
next prev parent reply other threads:[~2017-08-16 18:44 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-24 10:40 Simon Marchi
2017-07-24 10:40 ` [PATCH 2/3] gdbserver lwp_info: Initialize fields, use new/delete Simon Marchi
2017-07-25 9:58 ` Yao Qi
2017-07-25 10:19 ` Simon Marchi
2017-07-25 15:25 ` Yao Qi
2017-07-24 10:40 ` [PATCH 1/3] gdb lwp_info: Add destructor, initialize " Simon Marchi
2017-07-24 10:43 ` Simon Marchi
2017-07-25 9:39 ` Yao Qi
2017-07-24 10:40 ` [PATCH 3/3] Create arch_lwp_info class hierarchy Simon Marchi
2017-08-09 20:47 ` Simon Marchi
2017-08-11 20:13 ` [PATCH 0/3] " Pedro Alves
2017-08-12 11:31 ` Simon Marchi
2017-08-14 11:53 ` Pedro Alves
2017-08-16 18:44 ` Simon Marchi [this message]
2017-08-18 11:23 ` Pedro Alves
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=d5021e467857df4227744e5c15e95c48@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
--cc=simon.marchi@ericsson.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