From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2952 invoked by alias); 3 Dec 2014 17:36:48 -0000 Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-prs-owner@sourceware.org Received: (qmail 2929 invoked by uid 48); 3 Dec 2014 17:36:47 -0000 From: "daniel.parkinson1 at gmail dot com" To: gdb-prs@sourceware.org Subject: [Bug gdb/17676] New: gdb cannot print the address a pointer is pointing to returned by malloc Date: Wed, 03 Dec 2014 17:36:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: 7.7 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: daniel.parkinson1 at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-q4/txt/msg00336.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=17676 Bug ID: 17676 Summary: gdb cannot print the address a pointer is pointing to returned by malloc Product: gdb Version: 7.7 Status: NEW Severity: normal Priority: P2 Component: gdb Assignee: unassigned at sourceware dot org Reporter: daniel.parkinson1 at gmail dot com Overview After making a call to malloc to assign a memory address to a pointer that is a parameter of the function, gdb will print 0x0 as the address pointed to. Steps to reproduce Compiling the following code... #include #include #include #include void create_stack(int *other_name_stack); int *stack; int main(void) { create_stack(stack); return 0; } void create_stack(int *other_name_stack) { other_name_stack = malloc(sizeof(int)*10); if(other_name_stack == NULL) printf("Malloc failed: %s\n", strerror(errno)); printf("%p\n", (void *)other_name_stack); } Command: gcc -O0 -Wall -g teststack.c -o teststack Command: gdb ./teststack break create_stack n p other_name_stack Actual results. p other_name_stack will always return 0x0, but the if statement will never return true. Expected results I would expect to be able to see the memory address returned by malloc. Build Date & Hardware Linux jim-vm-ubuntu 3.16.0-031600-generic #201408031935 SMP Sun Aug 3 23:56:17 UTC 2014 i686 i686 i686 GNU/Linux Additional Info GNU gdb (Ubuntu 7.7-0ubuntu3.1) 7.7 -- You are receiving this mail because: You are on the CC list for the bug.