Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [ob/pushed] dwarf2read.c: fix latent buglet
@ 2015-08-03 18:01 Pedro Alves
  2015-08-03 18:07 ` Doug Evans
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2015-08-03 18:01 UTC (permalink / raw)
  To: gdb-patches

cust->includes is:

struct compunit_symtab
{
...
  struct compunit_symtab **includes;

gdb/ChangeLog:
2015-08-03  Pedro Alves  <palves@redhat.com>

	* dwarf2read.c (compute_compunit_symtab_includes): Use size of struct
	compunit_symtab pointer.
---
 gdb/dwarf2read.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 24a4022..b5ffd04 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -7983,7 +7983,7 @@ compute_compunit_symtab_includes (struct dwarf2_per_cu_data *per_cu)
       len = VEC_length (compunit_symtab_ptr, result_symtabs);
       cust->includes
 	= obstack_alloc (&dwarf2_per_objfile->objfile->objfile_obstack,
-			 (len + 1) * sizeof (struct symtab *));
+			 (len + 1) * sizeof (struct compunit_symtab *));
       for (ix = 0;
 	   VEC_iterate (compunit_symtab_ptr, result_symtabs, ix,
 			compunit_symtab_iter);
-- 
1.9.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [ob/pushed] dwarf2read.c: fix latent buglet
  2015-08-03 18:01 [ob/pushed] dwarf2read.c: fix latent buglet Pedro Alves
@ 2015-08-03 18:07 ` Doug Evans
  2015-08-03 18:14   ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Doug Evans @ 2015-08-03 18:07 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

On Mon, Aug 3, 2015 at 11:00 AM, Pedro Alves <palves@redhat.com> wrote:
> cust->includes is:
>
> struct compunit_symtab
> {
> ...
>   struct compunit_symtab **includes;
>
> gdb/ChangeLog:
> 2015-08-03  Pedro Alves  <palves@redhat.com>
>
>         * dwarf2read.c (compute_compunit_symtab_includes): Use size of struct
>         compunit_symtab pointer.
> ---
>  gdb/dwarf2read.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
> index 24a4022..b5ffd04 100644
> --- a/gdb/dwarf2read.c
> +++ b/gdb/dwarf2read.c
> @@ -7983,7 +7983,7 @@ compute_compunit_symtab_includes (struct dwarf2_per_cu_data *per_cu)
>        len = VEC_length (compunit_symtab_ptr, result_symtabs);
>        cust->includes
>         = obstack_alloc (&dwarf2_per_objfile->objfile->objfile_obstack,
> -                        (len + 1) * sizeof (struct symtab *));
> +                        (len + 1) * sizeof (struct compunit_symtab *));
>        for (ix = 0;
>            VEC_iterate (compunit_symtab_ptr, result_symtabs, ix,
>                         compunit_symtab_iter);

Bleah.
Since sizeof (struct symtab) < sizeof (struct compunit_symtab) (64 vs
112 for amd64)
I'd suggest this for the 7.10 branch too.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [ob/pushed] dwarf2read.c: fix latent buglet
  2015-08-03 18:07 ` Doug Evans
@ 2015-08-03 18:14   ` Pedro Alves
  0 siblings, 0 replies; 3+ messages in thread
From: Pedro Alves @ 2015-08-03 18:14 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

On 08/03/2015 07:06 PM, Doug Evans wrote:
> On Mon, Aug 3, 2015 at 11:00 AM, Pedro Alves <palves@redhat.com> wrote:
>> cust->includes is:
>>
>> struct compunit_symtab
>> {
>> ...
>>   struct compunit_symtab **includes;
>>
>> gdb/ChangeLog:
>> 2015-08-03  Pedro Alves  <palves@redhat.com>
>>
>>         * dwarf2read.c (compute_compunit_symtab_includes): Use size of struct
>>         compunit_symtab pointer.
>> ---
>>  gdb/dwarf2read.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
>> index 24a4022..b5ffd04 100644
>> --- a/gdb/dwarf2read.c
>> +++ b/gdb/dwarf2read.c
>> @@ -7983,7 +7983,7 @@ compute_compunit_symtab_includes (struct dwarf2_per_cu_data *per_cu)
>>        len = VEC_length (compunit_symtab_ptr, result_symtabs);
>>        cust->includes
>>         = obstack_alloc (&dwarf2_per_objfile->objfile->objfile_obstack,
>> -                        (len + 1) * sizeof (struct symtab *));
>> +                        (len + 1) * sizeof (struct compunit_symtab *));
>>        for (ix = 0;
>>            VEC_iterate (compunit_symtab_ptr, result_symtabs, ix,
>>                         compunit_symtab_iter);
> 
> Bleah.
> Since sizeof (struct symtab) < sizeof (struct compunit_symtab) (64 vs
> 112 for amd64)

Yes, but that's not the case here -- this is 'sizeof (foo *)' not
'sizeof (foo)'.  So it's actually pretty harmless.  Should have called
that out explicitly, sorry.

This was caught in the C++ conversion, where the "insert-casts"
script would generate:

       cust->includes
-         = obstack_alloc (&dwarf2_per_objfile->objfile->objfile_obstack,
+         = (struct symtab **) obstack_alloc (&dwarf2_per_objfile->objfile->objfile_obstack,
                         (len + 1) * sizeof (struct symtab *));

which would then fail to compile.

Thanks,
Pedro Alves


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-08-03 18:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-03 18:01 [ob/pushed] dwarf2read.c: fix latent buglet Pedro Alves
2015-08-03 18:07 ` Doug Evans
2015-08-03 18:14   ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox