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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:20:33+00:00 2026-05-16T22:20:33+00:00

I am trying to understand a C code from another programmer. Sometimes I get

  • 0

I am trying to understand a C code from another programmer. Sometimes I get segmentation faults and I think it could be due to stack overflow. I wonder whether in Visual Studio (or another way) is it possible to estimate in an easy way, given a call to a function, the size it will need on the stack when creating variables.

Thanks

  • 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-05-16T22:20:34+00:00Added an answer on May 16, 2026 at 10:20 pm

    The size of a frame on the stack is roughly the sum of the sizes of the parameters passed in plus the sum of the sizes of the local variables. There is also a little extra for the return address, base pointer, and perhaps some guard cookies for checking stack overruns.

    Example:

    int foo(int x, int y, char *string) {
      int array[10000];
      // ...
    }
    

    Integers in VC++ are 4 bytes each. A pointer is 4 bytes in a 32-bit executable, or 8 bytes in a 64-bit executable. So the parameters add up to 4+4+8. The local array is 40,000 bytes. This function consumes roughly 40 KB of stack. You could add up a lot of those before you overrun the stack.

    An actual stack overflow in a Windows program generally only happens with runaway recursion. The default stack size is pretty large (1 MB). You can get stack corruption by overrunning a buffer that’s on the stack.

    Chances are your crash has to do with accessing an array beyond its bounds or accessing through a pointer that isn’t pointing to valid memory (e.g., a NULL pointer).

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

Sidebar

Related Questions

I’m trying to understand code from http://www.yesodweb.com/book/conduits . After some fixes (like replacing Resource
I am trying to understand this inline assembly code which comes from _hypercall0 here
I'm trying to understand why my code get stuck in the for loop of
I am trying to understand a code from socket.io/examples/chat/app.js . I am not able
I'm trying to understand code that I bought so I can modify it. In
I am trying to understand a code, what exactly &(ipA[iLower + 1] stands for
I am now trying to understand some code and I have found a pattern,
I'm rather new to C++ and I'm trying to understand the code over on
I am trying to understand the following code: #include<stdio.h> #include<stdlib.h> #include<sys/io.h> #define baseport 0x378
I had a bit of a struggle trying to understand why my code was

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.