Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7744713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:50:00+00:00 2026-06-01T09:50:00+00:00

Background: I’m allocating my own machine contexts and stacks with the getcontext(3) / makecontext(3)

  • 0

Background: I’m allocating my own machine contexts and stacks with the getcontext(3) / makecontext(3) / setcontext(3) (ucontext.h; SUSv2, POSIX.1-2001) family of functions.

When I use gdb (version 6.1.1) to examine a stack while the thread is in one of these contexts I’ve allocated, it seems like gdb doesn’t know where the end (logical bottom) of the stack is. E.g., here’s a stack from x86 FreeBSD:

#0  0x2872d79f in poll () from /lib/libc.so.7
#1  0x28646e23 in poll () from /lib/libthr.so.3
#2  0x2869b267 in fdtask (task=0x28a3dc40, v=0x0) at fd.c:58
#3  0x2869c8dc in taskstart (y=681827392, x=0) at task.c:58
#4  0x00000000 in ?? ()
#5  0x28a3dc40 in ?? ()
#6  0x00000000 in ?? ()
#7  0x00000000 in ?? ()
…
#65 0x00000000 in ?? ()
…

(Yes, this is built on top of Russ Cox’ libtask library.)

This context’s execution begins at the taskstart function, but it seems like GDB can’t figure out that it should stop trying to read the stack even though it hits a return address of NULL in that frame.

My question is: Is there something I can do (by formatting the stack in some way, or setting a register, anything) to help GDB understand where the top of the stack is? Thanks.

Edit: Conclusion: It appears that one way gdb 6.1.1 detects the end of the stack is by checking that the stored frame pointer is NULL; I fixed the problem for my use case by modifying the x86 and amd64 makecontext(2) function to reset ebp or rbp to zero when initializing the new context. (In this case, I do not care about other architectures.) This problem disappears with gdb 7.1; presumably gdb 7.1 is capable of detecting end of stack through some other means, such as debuginfo.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T09:50:02+00:00Added an answer on June 1, 2026 at 9:50 am

    If GDB is using frame pointers to unwind the stack (pre-DWARF2 method) it stops when it gets to a null frame pointer, I believe. With DWARF2 things are much more complicated since the “frame pointer” is implicitly determined by the stack pointer combined with the insruction pointer and DWARF2 frame offset information for the current instruction, but essentially the effect is the same. Not sure which FreeBSD uses these days.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background I admit, this question stems from an ultimate lack of deep understanding of
Background: Our web app uses the jquery.constrain.js plugin to handle data entry in some
Background Consider the following: template <unsigned N> struct Fibonacci { enum { value =
Background I have a dimension table that has a single record for each day.
Background, Part 1 I have a form that collects both frequency and duration from
background: I work on an asp.net web application that is on a company intranet.
Background: I have this with rollup query defined in MySQL: SELECT case TRIM(company) when
Background: I'm writing a 'standard' (nothing special) web application in Ruby (not Rails) and
Background I have an existing extension designed to accompany a browser-based game (The extension
Background We need to develop a specialised CMS (internal use only) to support a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.