I want this to crash, but it doesn't

前端 未结 4 1193
不知归路
不知归路 2021-01-17 01:06

seriously.. I\'m an old hacker from the 80\'s and with some spare time on my hands thought I\'d \'C\' what the fuss is about

( my background is Forth, which does thi

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-17 01:48

    You miss main return address on the stack and probably overwrite some not critical data of main's caller so your program isn't crash. Moreover on some platforms (like powerpc for example) stack isn't used for function call and return address is stored in the special register (it pushed to the stack when it is required). So it is normal that this incorrect program doesn't crash.

    Update: moreover on some system stack grows up (to the higher addresses). At least in ARM stack growth is selectable.

提交回复
热议问题