From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 74558 invoked by alias); 17 Mar 2015 08:47:14 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 74545 invoked by uid 89); 17 Mar 2015 08:47:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: szxga03-in.huawei.com Received: from szxga03-in.huawei.com (HELO szxga03-in.huawei.com) (119.145.14.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (DES-CBC3-SHA encrypted) ESMTPS; Tue, 17 Mar 2015 08:47:11 +0000 Received: from 172.24.2.119 (EHLO szxeml433-hub.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BDF11066; Tue, 17 Mar 2015 16:45:31 +0800 (CST) Received: from [127.0.0.1] (10.111.68.57) by szxeml433-hub.china.huawei.com (10.82.67.210) with Microsoft SMTP Server id 14.3.158.1; Tue, 17 Mar 2015 16:44:42 +0800 Message-ID: <5507E977.2030003@huawei.com> Date: Tue, 17 Mar 2015 08:47:00 -0000 From: Zhang Zhen User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: CC: Subject: The return address of strtok is out of bounds in gdb Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.5507EA0A.0167,ss=1,re=0.001,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 34a880bba8a455379a206dda44354bfb X-SW-Source: 2015-03/txt/msg00058.txt.bz2 Hi, I found a problem with gdb-7.9 on my x86_64 machine. The return address is out of bounds by calling call strtok in gdb. But if we enter 'n', the return address is correct. I want to know this is a bug ? If so, how to resolve it ? It is easily reproduced as follows: Fs-Server:/opt/zhangzhen/gdb-7.9 # ./gdb/gdb -q ../strtok_test Reading symbols from ../strtok_test...done. (gdb) b 12 Breakpoint 1 at 0x4005c7: file strtok_test.c, line 12. (gdb) r Starting program: /opt/zhangzhen/strtok_test Breakpoint 1, main (argc=1, argv=0x7fffffffe358) at strtok_test.c:12 12 p1 = strtok(a0, se); (gdb) p p1 $1 = 0x0 (gdb) p p1 = strtok(a0, se) $2 = 0xffffffffffffe260 (gdb) n 13 printf("a0=%s\np1=%p\n", a0, p1); (gdb) p p1 $3 = 0x7fffffffe260 "start" (gdb) The source code of strtok_test is: 1 #include 2 #include 3 #include 4 5 int main(int argc, const char **argv) 6 { 7 char a0[] = {"start test! "}; 8 9 char *p1 = NULL; 10 char se[] = " "; 11 12 p1 = strtok(a0, se); 13 printf("a0=%s\np1=%p\n", a0, p1); 14 15 return 0; 16 } Best regards!