java中堆栈溢出_java – 由于堆栈溢出,C中通常会发生什么?
In C I’m aware that an array index out of bounds will produce a segmentation fault. Is it the same for a stack overflow in C and there will also be a segmentation fault i.e. same error type for a similar problem?
C中無法保證會出現分段錯誤. C標準說它是undefined behaviour并且保留它.它可能表現出來,取決于實現/平臺.
Or is it sometimes something much worse and a stack overflow in C could cause an operating system failure and force you to power cycle to get back? Or even worse, cause irreversible hardware damage? How bad effects can a stack overflow mistake have?
在現代操作系統中,很少有任何不幸發生在系統上;通常,只有程序會崩潰.現代操作系統使用various memory protection techniques.
It seems clear that the protection is better in Java than in C. Is it any better in C than in assembly / machine code or is it practically the same (lack of) protection in C as a assembly?
那是因為在Java中,內存是“被管理的”.在C中,它留給程序員;這是設計的. C編譯器最終生成機器代碼;所以它不會更好或更糟.明顯,
一個好的編譯器可以檢測到其中的一些問題并警告你,這與C語言相比,與匯編相比具有優勢.
總結
以上是生活随笔為你收集整理的java中堆栈溢出_java – 由于堆栈溢出,C中通常会发生什么?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java 输出脉冲信号_一种使用SOC精
- 下一篇: firefox 53支持java_Sel