Segmentation Fault doesn't come up immediately after accessing out-of-bound memory

后端 未结 5 982
旧时难觅i
旧时难觅i 2020-12-20 11:51

I wrote this piece of code and was expecting a segmentation fault quicly, but it seems I am allowed to access pieces of memory I shouldn\'t be able to.

#inc         


        
5条回答
  •  囚心锁ツ
    2020-12-20 12:17

    You are accessing outside the boundaries of tab, but you are still in your own stack space (probably because a stack frame is larger than a byte). You have full read / write access on your own stack. This is in fact the reason many cracks are possible.

    The segmentation fault occurs when your are going out of the bounds of you own stack. That's the moment you try to access a segment that's not yours (hence the name "segmentation fault").

提交回复
热议问题