Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: LRN <lrn1986@gmail.com>
To: gdb-patches@sourceware.org
Subject: Re: Program-assigned thread names on Windows
Date: Tue, 02 Aug 2016 09:47:00 -0000	[thread overview]
Message-ID: <40aaee01-35a5-9d3f-ceae-2bf4ca53a7b9@gmail.com> (raw)
In-Reply-To: <0515957c-dfd2-b119-d423-517917e8a5cd@gmail.com>


[-- Attachment #1.1.1: Type: text/plain, Size: 1158 bytes --]

On 28.07.2016 10:21, LRN wrote:
> On 28.07.2016 0:35, Jon Turney wrote:
>>
>> Doing a bit of testing with this patch...
>>
>> On 26/07/2016 18:15, LRN wrote:
>>> +	  named_thread = find_thread_ptid (named_thread_ptid);
>>
>> ... it seems this may return NULL (e.g. if the thread we are naming was 
>> short-lived and has already exited, or if the thread id was invalid) ...
>>
>>> +
>>> +	  thread_name = NULL;
>>> +	  thread_name_len = target_read_string (thread_name_target, &thread_name, 1025, 0);
>>> +	  if (thread_name_len > 0 && thread_name != NULL)
>>> +	    {
>>> +	      thread_name[thread_name_len - 1] = '\0';
>>> +	      if (thread_name[0] != '\0')
>>> +		{
>>> +		  xfree (named_thread->name);
>>
>> ... so this becomes a null dereference.
>>
>>> +		  named_thread->name = thread_name;
>>> +		}
>>> +	      else
>>> +		{
>>> +		  xfree (thread_name);
>>> +		}
>>
> 
> True.
> 
> The simplest fix for this is to turn the check
>> thread_name[0] != '\0'
> into
>> thread_name[0] != '\0' && named_thread != NULL
> 
> 

So, what happens now?

-- 
O< ascii ribbon - stop html email! - www.asciiribbon.org

[-- Attachment #1.1.2: 0x6759BA74.asc --]
[-- Type: application/pgp-keys, Size: 3540 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2016-08-02  9:47 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-23  9:25 LRN
2016-07-23  9:33 ` Eli Zaretskii
2016-07-23  9:43   ` LRN
2016-07-23 10:18     ` Eli Zaretskii
2016-07-23 16:43 ` John Baldwin
2016-07-23 17:01   ` LRN
2016-07-25 12:17     ` Jon Turney
2016-07-25 13:34       ` LRN
2016-07-25 14:07         ` Jon Turney
     [not found]           ` <e50e62e8-b3a8-cd4a-aff0-ea2097cf2412@gmail.com>
2016-07-25 21:33             ` LRN
2016-07-26  6:08               ` LRN
2016-07-26 13:18                 ` Jon Turney
2016-07-26 14:17                   ` LRN
2016-07-26 15:41                     ` LRN
2016-07-26 17:15                       ` LRN
2016-07-26 22:20                         ` Jon Turney
2016-07-27 21:35                         ` Jon Turney
2016-07-28  7:21                           ` LRN
2016-08-02  9:47                             ` LRN [this message]
2016-08-02 14:55                               ` Eli Zaretskii
2016-08-10  7:12                                 ` LRN
2016-08-10 12:15                                   ` Pedro Alves
2016-08-10 17:54                                     ` LRN
2016-08-10 18:45                                       ` Pedro Alves
2016-08-10 23:42                                         ` LRN
2016-08-11  0:39                                           ` 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=40aaee01-35a5-9d3f-ceae-2bf4ca53a7b9@gmail.com \
    --to=lrn1986@gmail.com \
    --cc=gdb-patches@sourceware.org \
    /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