public inbox for ecos-bugs@sourceware.org help / color / mirror / Atom feed
From: bugzilla-daemon@bugs.ecos.sourceware.org To: unassigned@bugs.ecos.sourceware.org Subject: [Bug 1001743] New: pthread name not NULL terminated. Date: Fri, 01 Feb 2013 10:11:00 -0000 [thread overview] Message-ID: <bug-1001743-777@http.bugs.ecos.sourceware.org/> (raw) Please do not reply to this email, use the link below. http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001743 Bug ID: 1001743 Summary: pthread name not NULL terminated. Product: eCos Version: CVS Hardware: All Architecture/Host All OS: Status: UNCONFIRMED Severity: minor Priority: low Component: POSIX Assignee: unassigned@bugs.ecos.sourceware.org Reporter: ecos@astekk.se CC: ecos-bugs@ecos.sourceware.org Class: Advice Request Classification: Unclassified The nthread->name is not NULL terminated when generating the pthread name on a stack that is not initialized to all zeroes. In pthread.cxx:592 ( http://ecos.sourceware.org/cgi-bin/cvsweb.cgi/ecos/packages/compat/posix/current/src/pthread.cxx?rev=1.16&content-type=text/x-cvsweb-markup&cvsroot=ecos ): #ifdef CYGVAR_KERNEL_THREADS_NAME // generate a name for this thread char *name = nthread->name; static char *name_template = "pthread.00000000"; pthread_t id = nthread->id; for( int i = 0; name_template[i]; i++ ) name[i] = name_template[i]; // dump the id, in hex into the name. for( int i = 15; i >= 8; i-- ) { name[i] = "0123456789ABCDEF"[id&0xF]; id >>= 4; } #endif In the for-loop copying the template into name, the terminating NULL from template is not copied over, which may leave name unterminated. Example output from a dump: Threads: Idle Thread pri = 31 state = R id = 1 stack base = 00007258 ptr = 00000000 size = 00000800 sleep reason NONE wake reason NONE queue = 00000000 wait info = 00000000 pthread.00000800 pri = 15 state = S id = 2 stack base = 00008a98 ptr = 00000000 size = 00001ef4 sleep reason WAIT wake reason NONE queue = 00002b88 wait info = 00000000 ext_events pri = 10 state = S id = 3 stack base = 00004a30 ptr = 00000000 size = 00000960 sleep reason WAIT wake reason NONE queue = 0000544c wait info = 00005310 <Not a string: 0xAD90 > pri = 15 state = R id = 4 stack base = 0000ae74 ptr = 00000000 size = 00001ef4 sleep reason NONE wake reason DONE queue = 00000000 wait info = 00000000 And, sample output from custom routine listing all threads, without rigorous thread name tests: ID Prio State Stack usage Name 1 31 r 524/2048 Idle Thread 2 15 S 1728/7924 pthread.00000800 3 10 S 316/2400 ext_events 4 15 R 2324/7924 pthread.00000C010▒h▒ The fix is easy enough, simply rewrite the for-loop into a do while-loop so the terminating char is copied over as well. -- You are receiving this mail because: You are the assignee for the bug. >From ecos-bugs-return-10018-listarch-ecos-bugs=sources.redhat.com@sourceware.org Fri Feb 01 10:11:47 2013 Return-Path: <ecos-bugs-return-10018-listarch-ecos-bugs=sources.redhat.com@sourceware.org> Delivered-To: listarch-ecos-bugs@sources.redhat.com Received: (qmail 661 invoked by alias); 1 Feb 2013 10:11:45 -0000 Received: (qmail 650 invoked by uid 22791); 1 Feb 2013 10:11:45 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from hagrid.ecoscentric.com (HELO mail.ecoscentric.com) (212.13.207.197) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 01 Feb 2013 10:11:35 +0000 Received: from localhost (hagrid.ecoscentric.com [127.0.0.1]) by mail.ecoscentric.com (Postfix) with ESMTP id DFCCF4680011 for <ecos-bugs@ecos.sourceware.org>; Fri, 1 Feb 2013 10:11:33 +0000 (GMT) Received: from mail.ecoscentric.com ([127.0.0.1]) by localhost (hagrid.ecoscentric.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0VMMDAE+jHWI; Fri, 1 Feb 2013 10:11:29 +0000 (GMT) From: bugzilla-daemon@bugs.ecos.sourceware.org To: ecos-bugs@ecos.sourceware.org Subject: [Bug 1001743] New: pthread name not NULL terminated. Date: Fri, 01 Feb 2013 10:11:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: eCos X-Bugzilla-Component: POSIX X-Bugzilla-Keywords: X-Bugzilla-Severity: minor X-Bugzilla-Who: ecos@astekk.se X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: low X-Bugzilla-Assigned-To: unassigned@bugs.ecos.sourceware.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter cc cf_class classification Message-ID: <bug-1001743-13@http.bugs.ecos.sourceware.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://bugs.ecos.sourceware.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Mailing-List: contact ecos-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <ecos-bugs.sourceware.org> List-Subscribe: <mailto:ecos-bugs-subscribe@sourceware.org> List-Post: <mailto:ecos-bugs@sourceware.org> List-Help: <mailto:ecos-bugs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs> Sender: ecos-bugs-owner@sourceware.org Delivered-To: mailing list ecos-bugs@sourceware.org X-SW-Source: 2013/txt/msg00052.txt.bz2 Content-length: 3244 Please do not reply to this email, use the link below. http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001743 Bug ID: 1001743 Summary: pthread name not NULL terminated. Product: eCos Version: CVS Hardware: All Architecture/Host All OS: Status: UNCONFIRMED Severity: minor Priority: low Component: POSIX Assignee: unassigned@bugs.ecos.sourceware.org Reporter: ecos@astekk.se CC: ecos-bugs@ecos.sourceware.org Class: Advice Request Classification: Unclassified The nthread->name is not NULL terminated when generating the pthread name on a stack that is not initialized to all zeroes. In pthread.cxx:592 ( http://ecos.sourceware.org/cgi-bin/cvsweb.cgi/ecos/packages/compat/posix/current/src/pthread.cxx?rev=1.16&content-type=text/x-cvsweb-markup&cvsroot=ecos ): #ifdef CYGVAR_KERNEL_THREADS_NAME // generate a name for this thread char *name = nthread->name; static char *name_template = "pthread.00000000"; pthread_t id = nthread->id; for( int i = 0; name_template[i]; i++ ) name[i] = name_template[i]; // dump the id, in hex into the name. for( int i = 15; i >= 8; i-- ) { name[i] = "0123456789ABCDEF"[id&0xF]; id >>= 4; } #endif In the for-loop copying the template into name, the terminating NULL from template is not copied over, which may leave name unterminated. Example output from a dump: Threads: Idle Thread pri = 31 state = R id = 1 stack base = 00007258 ptr = 00000000 size = 00000800 sleep reason NONE wake reason NONE queue = 00000000 wait info = 00000000 pthread.00000800 pri = 15 state = S id = 2 stack base = 00008a98 ptr = 00000000 size = 00001ef4 sleep reason WAIT wake reason NONE queue = 00002b88 wait info = 00000000 ext_events pri = 10 state = S id = 3 stack base = 00004a30 ptr = 00000000 size = 00000960 sleep reason WAIT wake reason NONE queue = 0000544c wait info = 00005310 <Not a string: 0xAD90 > pri = 15 state = R id = 4 stack base = 0000ae74 ptr = 00000000 size = 00001ef4 sleep reason NONE wake reason DONE queue = 00000000 wait info = 00000000 And, sample output from custom routine listing all threads, without rigorous thread name tests: ID Prio State Stack usage Name 1 31 r 524/2048 Idle Thread 2 15 S 1728/7924 pthread.00000800 3 10 S 316/2400 ext_events 4 15 R 2324/7924 pthread.00000C010▒h▒ The fix is easy enough, simply rewrite the for-loop into a do while-loop so the terminating char is copied over as well. -- You are receiving this mail because: You are on the CC list for the bug. >From ecos-bugs-return-10019-listarch-ecos-bugs=sources.redhat.com@sourceware.org Fri Feb 01 10:50:53 2013 Return-Path: <ecos-bugs-return-10019-listarch-ecos-bugs=sources.redhat.com@sourceware.org> Delivered-To: listarch-ecos-bugs@sources.redhat.com Received: (qmail 25696 invoked by alias); 1 Feb 2013 10:50:52 -0000 Received: (qmail 25686 invoked by uid 22791); 1 Feb 2013 10:50:48 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,KHOP_THREADED,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from hagrid.ecoscentric.com (HELO mail.ecoscentric.com) (212.13.207.197) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 01 Feb 2013 10:50:43 +0000 Received: from localhost (hagrid.ecoscentric.com [127.0.0.1]) by mail.ecoscentric.com (Postfix) with ESMTP id 243D64680011 for <ecos-bugs@ecos.sourceware.org>; Fri, 1 Feb 2013 10:50:40 +0000 (GMT) Received: from mail.ecoscentric.com ([127.0.0.1]) by localhost (hagrid.ecoscentric.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qT-+l0A1GVcd; Fri, 1 Feb 2013 10:50:39 +0000 (GMT) From: bugzilla-daemon@bugs.ecos.sourceware.org To: ecos-bugs@ecos.sourceware.org Subject: [Bug 1001743] pthread name not NULL terminated. Date: Fri, 01 Feb 2013 10:50:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: eCos X-Bugzilla-Component: POSIX X-Bugzilla-Keywords: X-Bugzilla-Severity: minor X-Bugzilla-Who: ecos@astekk.se X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: low X-Bugzilla-Assigned-To: unassigned@bugs.ecos.sourceware.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: <bug-1001743-13-ugXHjBFcp8@http.bugs.ecos.sourceware.org/> In-Reply-To: <bug-1001743-13@http.bugs.ecos.sourceware.org/> References: <bug-1001743-13@http.bugs.ecos.sourceware.org/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://bugs.ecos.sourceware.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Mailing-List: contact ecos-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <ecos-bugs.sourceware.org> List-Subscribe: <mailto:ecos-bugs-subscribe@sourceware.org> List-Post: <mailto:ecos-bugs@sourceware.org> List-Help: <mailto:ecos-bugs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs> Sender: ecos-bugs-owner@sourceware.org Delivered-To: mailing list ecos-bugs@sourceware.org X-SW-Source: 2013/txt/msg00053.txt.bz2 Content-length: 310 Please do not reply to this email, use the link below. http://bugs.ecos.sourceware.org/show_bug.cgi?id\x1001743 --- Comment #1 from Andreas Stenius <ecos@astekk.se> --- Or, knowing the template is 16 chars, add a name[16] = '\0'; -- You are receiving this mail because: You are on the CC list for the bug.
next reply other threads:[~2013-02-01 10:11 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-02-01 10:11 bugzilla-daemon [this message] 2013-02-01 10:50 ` [Bug 1001743] " bugzilla-daemon 2013-02-03 13:41 ` bugzilla-daemon
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=bug-1001743-777@http.bugs.ecos.sourceware.org/ \ --to=bugzilla-daemon@bugs.ecos.sourceware.org \ --cc=unassigned@bugs.ecos.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: linkBe 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).