Alessandroempire
Alessandroempire

Reputation: 1699

C Stack smashing detected after calling a function

Got a problem which to me make no sense. So here goes:

I have a function that counts how many times a word appears in a file, thus this function return a integer (int). So on another function it uses the "counter". Now for some reason it decided to start launching a stack smashing detected error. I had been testing it for 2 weeks the whole program and it worked to perfection. Now I get that error, which really makes no sense. What in the world is going on? And the error is right there, after the function has counter and it return, it launches the stack smashing detected error.

Edit: I keep searching, and yes i get a stack smashing detected error when returning a int function. Any ideas? If i take that code out, it does not crash. Really i have no idea

Any suggestion?

Thanks...

Upvotes: 0

Views: 2247

Answers (1)

thkala
thkala

Reputation: 86333

May I suggest compiling your program with debugging information and running it under Valgrind? See also this related question.

If you need it, I have posted some hints on using Valgrind in an older answer of mine.

Upvotes: 2

Related Questions