public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "daniel.parkinson1 at gmail dot com" <sourceware-bugzilla@sourceware.org>
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	[thread overview]
Message-ID: <bug-17676-4717@http.sourceware.org/bugzilla/> (raw)

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 <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>

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.


             reply	other threads:[~2014-12-03 17:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-03 17:36 daniel.parkinson1 at gmail dot com [this message]
2024-01-02 17:51 ` [Bug gdb/17676] " ssbssa at sourceware dot org

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-17676-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@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: link
Be 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).