07-27-2023, 11:24 AM
I made the core dumped error with the two pieces of codes below:
//test.cpp
int main()
{
int *p = new int;
*p = 100;
delete p;
delete p;
return 0;
}
//test2.cpp
int main()
{
int *p = new int;
*p = 100;
delete p;
*p = 111;
std::cout<<*p<<std::endl;
return 0;
}
Gdb told me that the first piece of code got core dumped because of the signal SIGABRT, whereas the second piece of code got core dumped because of the signal SIGSEGV.
Could you tell what is the difference?
//test.cpp
int main()
{
int *p = new int;
*p = 100;
delete p;
delete p;
return 0;
}
//test2.cpp
int main()
{
int *p = new int;
*p = 100;
delete p;
*p = 111;
std::cout<<*p<<std::endl;
return 0;
}
Gdb told me that the first piece of code got core dumped because of the signal SIGABRT, whereas the second piece of code got core dumped because of the signal SIGSEGV.
Could you tell what is the difference?