bug-gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AMD64 backtrace problem on FreeBSD-CURRENT


From: David Xu
Subject: AMD64 backtrace problem on FreeBSD-CURRENT
Date: Thu, 10 Mar 2005 22:19:43 +0800
User-agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.5) Gecko/20050306

I have a weird stack backtrace problem on FreeBSD amd64,
Here is the demo code:
--------------
#include <ucontext.h>
#include <stdio.h>

void f()
{
       printf("hello\n");
       exit(0);
}

int main()
{
       ucontext_t uc;
       char *p;
       int len = 1024 * 64;

       getcontext(&uc);
       p = malloc(len);
       uc.uc_stack.ss_sp = p;
       uc.uc_stack.ss_size = len;
       makecontext(&uc, f, 0);
       setcontext(&uc);
       return (0);
}
--------------
when debugging, I got weird stack backtrace:

address@hidden:/home/davidxu/ctx> cc -g -o ctx ctx.c
address@hidden:/home/davidxu/ctx> gdb ./ctx
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "amd64-marcel-freebsd"...
(gdb) break main
Breakpoint 1 at 0x40082b: file ctx.c, line 14.
(gdb) break 6
Breakpoint 2 at 0x400804: file ctx.c, line 6.
(gdb) run
Starting program: /dumpster/home/davidxu/ctx/ctx

Breakpoint 1, main () at ctx.c:14
14              int len = 1024 * 64;
(gdb) n
16              getcontext(&uc);
(gdb)
17              p = malloc(len);
(gdb)
18              uc.uc_stack.ss_sp = p;
(gdb)
19              uc.uc_stack.ss_size = len;
(gdb)
20              makecontext(&uc, f, 0);
(gdb)
21              setcontext(&uc);
(gdb)

Breakpoint 2, f () at ctx.c:6
6               printf("hello\n");
(gdb) bt
#0  f () at ctx.c:6
#1  0x000000080066cdf4 in makecontext () from /lib/libc.so.6
#2  0xd0d0d0d0d0d0d0d0 in ?? ()
#3  0x0000000000000000 in ?? ()
#4  0x0000000000000000 in ?? ()
#5  0x0000000000000000 in ?? ()
#6  0x0000000000000000 in ?? ()
#7  0x0000000000000000 in ?? ()
#8  0x0000000000000000 in ?? ()
Error accessing memory address 0x512000: Bad address.
(gdb)

What can cause it to dump non-exist frame ?

David Xu






reply via email to

[Prev in Thread] Current Thread [Next in Thread]