Stack Smashing here is actually caused due to a protection mechanism used by gcc to detect buffer overflow errors.
gcc adds protection variables (called canaries) which have known values. A stack overflow error causes corruption of this variable resulting in SIGABRT to terminate the program.
![](https://img.haomeiwen.com/i15662273/76998b14922c10e9.png)
![](https://img.haomeiwen.com/i15662273/4327c8adb93ec542.png)
you can try disabling this protection of gcc using option -fno-stack-protector
while compiling. In that case you will get a different error, most likely a segmentation fault as you are trying to access an illegal memory location. Note that -fstack-protector
should always be turned on for release builds as it is a security feature.
References:
https://stackoverflow.com/questions/1345670/stack-smashing-detected
https://www.educative.io/edpresso/what-is-the-stack-smashing-detected-error
网友评论