V
vashwath
Probably OT, but I did not get any suitable group to discuss this as
this post also has question regarding malloc.
For my current project I am inserting the following statements
randomly.
{
int x = 0;
if (x == 1)
exit(0);
}
I can exit by setting x to 1(Using Debugger) at anytime I want.I found
that if there is any mistake in the like dynamic array overflow, The
program will exit with SIGSEGV.If there is nothing wrong with code
until exiting, the program will exit normally.I know this does not work
always, but I am able to find certain mistakes.
Now, Have a look at the following piece of code.
{
int x = 0;
if (x == 1)/*I can exit when ever I want by setting x to 1 using
debugger*/
exit(0); /*Here the program is exiting normally*/
}
some_var = malloc(some size);
{
int x = 0;
if (x == 1)
exit(0);/*Here the program is exiting with SIGSEGV*/
}
When the exit statement is executed after malloc the program is exiting
with SIGSEGV, but if the exit statement is executed just before malloc,
it is exiting normally.Does this mean there is some problem with
malloc(I don't think so)?Or what is causing this strange behavior?
I am using gcc on Linux for compilation.
this post also has question regarding malloc.
For my current project I am inserting the following statements
randomly.
{
int x = 0;
if (x == 1)
exit(0);
}
I can exit by setting x to 1(Using Debugger) at anytime I want.I found
that if there is any mistake in the like dynamic array overflow, The
program will exit with SIGSEGV.If there is nothing wrong with code
until exiting, the program will exit normally.I know this does not work
always, but I am able to find certain mistakes.
Now, Have a look at the following piece of code.
{
int x = 0;
if (x == 1)/*I can exit when ever I want by setting x to 1 using
debugger*/
exit(0); /*Here the program is exiting normally*/
}
some_var = malloc(some size);
{
int x = 0;
if (x == 1)
exit(0);/*Here the program is exiting with SIGSEGV*/
}
When the exit statement is executed after malloc the program is exiting
with SIGSEGV, but if the exit statement is executed just before malloc,
it is exiting normally.Does this mean there is some problem with
malloc(I don't think so)?Or what is causing this strange behavior?
I am using gcc on Linux for compilation.