public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: Patrick Frants <osscontribute@gmail.com>, <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Fix faulty use of obstack_free() to *shrink* dont_print_statmem_obstack. Instead use obstack_blank_fast() with a "negative" size. A real stack data structured would be appropriate here. Added unit test gdb/testsuite/gdb.cp/printstaticrecursion.exp.
Date: Mon, 23 Oct 2017 17:17:00 -0000	[thread overview]
Message-ID: <0d612f89-a3a9-afea-965b-7c364b660235@ericsson.com> (raw)
In-Reply-To: <a983ffc6-25d8-0553-3e4d-69dc3fec72df@ericsson.com>

On 2017-10-23 12:09 PM, Simon Marchi wrote:
>> diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
>> index fb9bfd9..8f9658d 100644
>> --- a/gdb/cp-valprint.c
>> +++ b/gdb/cp-valprint.c
>> @@ -370,14 +370,9 @@ cp_print_value_fields (struct type *type, struct type *real_type,
>>  
>>  	  if (obstack_final_size > statmem_obstack_initial_size)
>>  	    {
>> -	      /* In effect, a pop of the printed-statics stack.  */
>> -
>> -	      void *free_to_ptr =
>> -		(char *) obstack_next_free (&dont_print_statmem_obstack) -
>> -		(obstack_final_size - statmem_obstack_initial_size);
>> -
>> -	      obstack_free (&dont_print_statmem_obstack,
>> -			    free_to_ptr);
>> +          /* In effect, a pop of the printed-statics stack.  */
>> +          size_t shrink_bytes = statmem_obstack_initial_size - obstack_final_size;

Hmm, size_t is unsigned, maybe it would be better to use ssize_t?

>> +          obstack_blank_fast(&dont_print_statmem_obstack, shrink_bytes);
> 
> The indentation should be 1 tab + 6 spaces.
> 
>>  	    }
>>  
>>  	  if (last_set_recurse != recurse)
> 
> The code below that (which seems to be handling a similar situation, but for arrays) uses
> obstack_next_free as well.  Is there the same problem there?

Never mind about this, I saw your other message after reading this one.

Simon

  reply	other threads:[~2017-10-23 17:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-19  9:31 Patrick Frants
2017-10-19 10:18 ` Patrick Frants
2017-10-23 16:09 ` Simon Marchi
2017-10-23 17:17   ` Simon Marchi [this message]
2017-10-23 19:37     ` Simon Marchi
2017-10-23 19:55       ` osscontribute
2017-10-23 20:07         ` Simon Marchi
2017-10-23 20:04       ` 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=0d612f89-a3a9-afea-965b-7c364b660235@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    --cc=osscontribute@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).