On Thu, 19 Jun 2003, Orna Agmon wrote:

> Hello eveyone,
>
> I was wondering if there was anything that detected C stack overflow in a
> nice way (i.e., not by having to cut down my program until I stop getting
> a segmentation fault on the first line of main).

if this is linux on IA32, kernel 2.4, you can, should and must use
valgrind - but only during debugging (it slows the program tremendously).
i think you already know about valgrind, however, so i'm not sure what is
it that it is that you're asking for here....

> In details:
>
> I have a program that looks somewhat like that:
>
> typedef struct{
>  /*a huge struct definition*/
> } a_t;
>
> int main(int argc, char *argv){
> a_t a;
> return 0;
> }
>
> and I want to get something politer than a segmentation fault.
>  I found some info on preventing attacks on the stack, so it seems to me
> that it should be possible to do this in a non- hostile manner.
>
> BTW, it is not a problem of lack of memory- the same struct can be
> allocated on the heap.

allocating huge structs on the stack, in a non-trivial program, is a
definite no-no. don't do that.

-- 
guy

"For world domination - press 1,
 or dial 0, and please hold, for the creator." -- nob o. dy


--------------------------------------------------------------------------
Haifa Linux Club Mailing List (http://www.haifux.org)
To unsub send an empty message to [EMAIL PROTECTED]


Reply via email to