Very Large Stack Variables
The other major cause of a stack overflow results from an attempt to allocate more memory on the stack than will fit, for example by creating local array variables that are too large. For this reason some authors recommend that arrays larger than a few kilobytes should be allocated dynamically instead of as a local variable.
An example of a very large stack variable in C:
int foo { double x; }The declared array consumes 8 megabytes of data (assuming each double is 8 bytes); if this is more memory than is available on the stack (as set by thread creation parameters or operating system limits), a stack overflow will occur.
Stack overflows are made worse by anything that reduces the effective stack size of a given program. For example, the same program being run without multiple threads might work fine, but as soon as multi-threading is enabled the program will crash. This is because most programs with threads have less stack space per thread than a program with no threading support. Similarly, people new to kernel development are usually discouraged from using recursive algorithms or large stack buffers.
Read more about this topic: Stack Overflow
Famous quotes containing the words large, stack and/or variables:
“The artistic temperament is a disease that affects amateurs.... Artists of a large and wholesome vitality get rid of their art easily, as they breathe easily or perspire easily. But in artists of less force, the thing becomes a pressure, and produces a definite pain, which is called the artistic temperament.”
—Gilbert Keith Chesterton (18741936)
“Farewell to barn and stack and tree,
Farewell to Severn shore.
Terence, look your last at me,
For I come home no more.”
—A.E. (Alfred Edward)
“The variables are surprisingly few.... One can whip or be whipped; one can eat excrement or quaff urine; mouth and private part can be meet in this or that commerce. After which there is the gray of morning and the sour knowledge that things have remained fairly generally the same since man first met goat and woman.”
—George Steiner (b. 1929)