Stack overflows

Nov 05, 2003 5 Replies

I use intel processers,Arm and X86. I want to find stack overflow. Somone said that it is possible to use a "stack descriptor" in an Intel processor to catch exactly this kind of fault. But I don't know how? Does anyone know this?


If you're running in a protected mode, the Intel segmentation model gives a possibility to catch an addressing attempt outside of a segment. The segment boundaries are in the segment descriptor, which is a table element in the global descriptor table (GDT) or local descriptor table (LDT) of the process executing. The tables are built by the kernel running the protected mode environment.

The detailed instructions depend heavily upon the environment you're running your code in.

For hardware details, get a book on Intel 386+ architecture and look at protected mode programming model. The segmentation is already in 80286, but in limited 16 bit form.

HTH

Tauno Voipio tauno voipio @ iki fi

or if you're using paged memory model, using a "guard page" is a popular and simple arrangement.

-bryan

a

segment

process

running

but

Have a look at MPATROL and EFENCE. They help you track down memory related bugs. If nothing else they will help you understand what you should be looking for in terms of tools.

Regards Sergio Masci

formatting link
- optimising structured PIC BASIC compiler

For older, non-MMU processors, the tactic always has been to 'fill' the stack with a certain 'guard' pattern on thread initialisation, and check the guard pattern at the top once in a while. (in interrupt, for example)

This detects stack overflows but doesn't prevent the accompanying damage.

Wumpus

It does if the only damage is the corruption of the guard pattern.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required