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 8003881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:46:07+00:00 2026-06-04T16:46:07+00:00

I have a very compute-intensive module in which I’ve added stack-tracing to be able

  • 0

I have a very compute-intensive module in which I’ve added stack-tracing to be able to find specific problems. Although the application is allowed to run slower when this stack-tracing is enabled, it must not run 10 times slower. That’s why I am not using the StackWalk routines from DBGHELP.DLL, but I walk the stack myself using the frame pointers (so I don’t use the Frame Pointer Omission compiler option).

In most cases, getting the call stack works correctly and is very fast, but in some cases, my logic fails because one of the frame pointers points to an address outside the stack (not much, just a little bit).

I know that this is probably an error somewhere, but to be able to make my code safer, I need a way to check whether a frame-pointer points to a memory location within the stack of the current thread or not. The application is 64-bit and runs under Windows.

The code at How to get thread stack information on Windows? probably solves the problem, but since this calls other functions, it probably makes my code run much slower (to be honest, I didn’t test it).

I also found some inline assembly code that should perform the trick (http://nasutechtips.blogspot.com/2011/01/thread-information-block-tib-and-fs.html), but inline assembly isn’t supported by Microsoft’s 64-bit C++ compiler.

Also the intrinsic __readfsqword doesn’t seem to work on 64-bit.

Any other suggestions on how to get the TIB on 64-bit as fast as possible?

  • 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-04T16:46:09+00:00Added an answer on June 4, 2026 at 4:46 pm

    Found it, the following code does the trick:

    #include <windows.h>
    #include <winnt.h>
    
    struct _TEB
       {
       NT_TIB NtTib;
       // Ignore rest of struct
       };
    
    void *startOfStack;
    startOfStack = NtCurrentTeb()->NtTib.StackBase;
    std::cout << "startOfStack = " << startOfStack << std::endl;
    

    I looked to the definition of NtCurrentTeb() in winnt.h and it looks like this is a very low level function, so it will probably be fast enough to get what I want.

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

Sidebar

Related Questions

I have very specific question, I cannot find a problem. I try update some
I have a very memory-intensive C# desktop application and my question is: Is increasing
I have two very large matrices (60x25000) and I'd like to compute the correlation
I have to store two files A and B which are both very large
In my website i have a database intensive page which i cache for 5
I have a set of arrays that are very large and expensive to compute,
I have very newbie question. How can i check that object of model is
I have very obvious problem, but still did not found solution to it. I
I have very simple XML in a string that I'm trying to load via
We have very old application deployed in Linux server. We are using the RollingFileAppender

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.