Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 566 Vote(s) - 3.49 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What is the difference between SIGABRT and SIGSEGV

#1
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?
Reply

#2
Deleting a pointer twice is undefined behavior, which means anything can happen. In this case, it results in the `SIGABRT` signal being issued.

Accessing memory which does not belong to the program is also undefined behavior which in this case results in segmentation fault and `SIGSEGV` is issued.


- `SIGABRT` indicates an error detected by the program itself and reported by calling [`abort`][1].
- `SIGSEGV` indicates an invalid access to valid memory.


[1]:

[To see links please register here]

Reply

#3
The SIGABRT is **explicitly detected and signaled** by the implementation of _delete_ whose detected the invalidity of the second delete. It is launch by calling the _abort_ function

The SIGSEGV is different, it is **undergoing** rather than detected by a check in a library like the previous, it is launch through the memory management of the OS

see

[To see links please register here]

Reply

#4
Both of these examples are *undefined behaviour*, this means according to c++ the compiler (and system) can do whatever it wants.

- In case 1, there is likely a check for the double delete of a pointer, therefore `SIGABRT` is signaled. `SIGABRT` means *abnormal termination condition, as is e.g. initiated by abort()*.
- In case 2, the system detects your deference of a deleted pointer and
creates a `SIGSEGV` signal. `SIGSEGV` means *invalid memory access (segmentation fault)*

But both are still UB, so this is just a feature of your current compiler/os/system. The difference between the errors is clear from the definition of the errors [here][1]. One is an abort, usually generated by the compiler or coder. One is caused by invalid memory access, usually signaled by the operating system or hardware.


[1]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through