From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4104 invoked by alias); 24 Dec 2009 21:08:36 -0000 Received: (qmail 4095 invoked by uid 22791); 24 Dec 2009 21:08:36 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 24 Dec 2009 21:08:31 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBOL8TBi023035 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 24 Dec 2009 16:08:29 -0500 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBOL8Q8X010883 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 24 Dec 2009 16:08:28 -0500 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.3) with ESMTP id nBOL8QDr030093; Thu, 24 Dec 2009 22:08:26 +0100 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.3/Submit) id nBOL8Q48030091; Thu, 24 Dec 2009 22:08:26 +0100 Date: Thu, 24 Dec 2009 21:08:00 -0000 From: Jan Kratochvil To: Aravinda Cc: gdb@sourceware.org Subject: Re: Problem with manual watchpoints Message-ID: <20091224210825.GA29926@host0.dyn.jankratochvil.net> References: <26eb53620912241247i718992d6i422451f4b7f9931@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <26eb53620912241247i718992d6i422451f4b7f9931@mail.gmail.com> User-Agent: Mutt/1.5.20 (2009-08-17) X-IsSubscribed: yes 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 X-SW-Source: 2009-12/txt/msg00151.txt.bz2 On Thu, 24 Dec 2009 21:47:06 +0100, Aravinda wrote: > a = malloc(20); > __add_watchpoint(getpid(), &a[20]); > > for (i = 0; i < 25; i ++) { > /* getc(stdin); ----> without this, no SIGTRAP is getting generated */ > printf("Accessing now %x\n", &a[i]); > a[i]++; > } What is the type of "a"? After "a = malloc(20);" you can access elements a[0]...a[19] but a[20] is already after the allocated array size. Also the loop is till "i < 25" but you have allocated only 20 elements. In fact you may have allocated only 5 elements if "*a" is "int" etc. > However, if I just add a 'getc(stdin)' before accessing every element, it > does get the exception on accessing a[20]. You have data corruption in your program so it behaves very unpredictably. Please run some valgrind or mudflap on it. At least try it first in userland if it should be a kernel module. Regards, Jan