如果不断访问超过malloc()分配大小的内存,Linux glibc中会发生什么 [英] what happens in linux glibc if keep increasingly accessing memory exceeding malloc() allocated size

查看:298
本文介绍了如果不断访问超过malloc()分配大小的内存,Linux glibc中会发生什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于人们只是在UB停留而删除了该主题...

remove this topic as people simply stop at UB...

推荐答案

在分配的内存之外访问内容是未定义的行为.什么都可能发生.我听说鼻恶魔是有可能的.

Accessing stuff outside of the allocated memory is undefined behavior. Anything can happen. I hear nasal demons are a possibility.

如果您真的很幸运,可能会遇到访问冲突/段错误.如果您不走运,则程序中的其他变量可能会被覆盖,或者看不到任何可观察的事物,月亮可能变成7UP徽标,或者可能是您的右鼻孔挤出了一些讨厌的东西.

If you are really lucky, you might get an access violation/segfault. If you aren't lucky, then some other variable in the program may be overwritten, or nothing observable may happen, The moon may turn into the 7UP logo, or maybe something nasty squeezes out of your right nostril.

这篇关于如果不断访问超过malloc()分配大小的内存,Linux glibc中会发生什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆