From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 55052 invoked by alias); 27 Jul 2016 21:35:46 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 55040 invoked by uid 89); 27 Jul 2016 21:35:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=H*M:47f8, Hx-spam-relays-external:ESMTPA X-HELO: out4-smtp.messagingengine.com Received: from out4-smtp.messagingengine.com (HELO out4-smtp.messagingengine.com) (66.111.4.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 27 Jul 2016 21:35:35 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id A2A1E20534; Wed, 27 Jul 2016 17:35:33 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute5.internal (MEProxy); Wed, 27 Jul 2016 17:35:33 -0400 Received: from [192.168.1.102] (host86-179-112-245.range86-179.btcentralplus.com [86.179.112.245]) by mail.messagingengine.com (Postfix) with ESMTPA id 35682F29EE; Wed, 27 Jul 2016 17:35:33 -0400 (EDT) Subject: Re: Program-assigned thread names on Windows References: <5052d495-ea40-b364-96ea-9e68c90bd747@gmail.com> <14995502.J10EtrK3xV@ralph.baldwin.cx> <6a3446f9-63dc-67a1-3702-203d77c8d85d@gmail.com> <0cabec98-8411-2c3a-98d0-3d950de02bc5@gmail.com> <28023f06-f99c-77d1-10cf-5243f2a082a4@gmail.com> <0e59216f-77cb-608a-aa39-578c2610eda1@dronecode.org.uk> <0f064b2b-6b51-f132-caa6-a4c1a85585a3@gmail.com> <2c9f43ec-af6f-cdaf-8e45-b251588b9b89@gmail.com> Cc: LRN To: gdb-patches@sourceware.org From: Jon Turney Message-ID: Date: Wed, 27 Jul 2016 21:35:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <2c9f43ec-af6f-cdaf-8e45-b251588b9b89@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2016-07/txt/msg00357.txt.bz2 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); > + }