在改别人代码时,运行报错:

Run-Time Check Failure #2 Stack around the variable ‘buffer’ was corrupted

这表明你对某变量的赋值操作,超出了其内存范围。

例,在我的代码中大致是这样的:

char buffer[10];
sprintf(buffer, "D:\\user\\test\\exp10.epoch03.autosave");

很明显,这里我给buffer赋值的字符串长度超出了其定义时分配的内存范围。

找到问题后突然感觉……真是好白痴的问题啊~

不过刚看到时还是挺没有头绪的,尤其是出问题的这个变量还用了buffer这种大众化的名字……

而且这种运行时问题是不会提示哪行出错的,茫茫多代码啊!这回充分体会到步进式debug是多么的重要了。

另外,在网上查看相关问题,几乎都是char[]+sprintf引起的,以后看到可以快速定位了。

相关问题引用:

Run-Time Check Failure #2 - Stack around the variable — was corrupted

奇怪的Stack around the variable was corrupted现象解析 以及 sprintf 的奇怪现象?谁能解释?

Run-Time Check Failure #2 Stack around the variable ‘xxx’ was corrupted的更多相关文章

  1. VS2008中Run-Time Check Failure #2 - Stack around the variable 'xxx' was corrupted 错误解决方法

    问题 : 在用VS2008写一段代码,算法都没有问题,但是调试的时候发现出了main之后就报 Stack around the variable 'xxx' was corrupted 的错误,后来发 ...

  2. c++. Run-Time Check Failure #2 - Stack around the variable 'cc' was corrupted.

    Run-Time Check Failure #2 - Stack around the variable 'cc' was corrupted. char cc[1024];   //此处如果索引值 ...

  3. Run-Time Check Failure #2 - Stack around the variable 's' was corrupted. 出现了 。

    程序中存在内存越界,注意数组大小和数据大小.

  4. vs中 Stack around the variable 'XXX' was corrupted.

    https://blog.csdn.net/hou09tian/article/details/75042206 把 project->配置属性->c/c++->代码生成->基 ...

  5. Run-Time Check Failure #2 - Stack around the variable 'ucPriKey' was corrupt

    Run-Time    Check    Failure    #2        一般是栈被破坏,你的代码可能有缓冲区溢出一类的问题. Run-Time Check Failure #2 - Sta ...

  6. Stack around the variable 'szStr' was corrupted.

    错误:stack around the variable “XX” was corrupted.,中文翻译就是“在变量XX周围的堆栈已损坏”. 把 project->配置属性->c/c++ ...

  7. stack around the variable “XX” was corrupted

    晚上花了几个小时fix了这个恼人的BUG!“在变量XX周围的堆栈已损坏” 在网上找到的解释是: 把“project->配置属性->c/c++->代码生成->基本运行时检查 设置 ...

  8. vs中“Stack around the variable was corrupted”的解决方案

    把 project->配置属性->c/c++->代码生成->基本运行时检查 为 默认值 就不会报本异常.具体原因正在研究中... 如果改为其他就有exception. exce ...

  9. 运行时错误:“stack around the variable…was corrupted”

    造冰箱的大熊猫@cnblogs 2018/11/1 引发问题的代码片段如下 WORD var; scanf ( "%d", &var ); 包含上述代码的程序,编译正常,运 ...

随机推荐

  1. 彻底搞清楚Java并发 (一) 基础

    多线程编程是为了让程序运行得更快,但是不是说,线程创建地越多越好,线程切换的时候上下文切换,以及受限于硬件和软件资源的限制问题 上下文切换 单核CPU同样支持多线程编程,CPU通过给每个线程分配CPU ...

  2. Adb 获取手机信息

    adb shell getprop [ro.product.board]: [herring][ro.product.brand]: [google][ro.product.cpu.abi2]: [a ...

  3. BarTender复合条形码中的分隔符模式详解

    在BarTender 10.1中,支持使用BarTender分隔符模式的复合条形码符号体系包括GS1 Composite和GS1 DataBar (RSS).本文小编给大家详细讲解BarTender分 ...

  4. PHPCMS V9 全站通用日期时间标签

    用PHPCMS V9 建站时,经常会用到时间标签,它是通用标签调用-日期时间格式化,适用全站. 1.日期时间格式化显示: a\标准型:{date('Y-m-d H:i:s', $rs['inputti ...

  5. nano-sql.js的基本操作

    nano-sql是一个小而快的数据库引擎, 他支持联合查询, 分组, 事务, ORM等功能, 支持 内存, indeedDB, Local Storage, WebSQL, Level DB 注意第一 ...

  6. Grunt--Less

    摘要: 之前介绍了自动构建工具Grunt,其中有一个模块是"grunt-contrib-less",下面是配置Grunt自动编译less文件. 安装: Grunt是基于node,功 ...

  7. html5页面平滑切换实现以及问题(20160120更新)

    注:本文是基于手机端 Hybrid APP 讨论,而不是普通的PC端网页 >> 之前的页面跳转方式: 比如有这两个页面:A.html  B.html,  A B 是纯HTML实现,没有采用 ...

  8. 8 -- 深入使用Spring -- 2...6 Spring 4.0 增强的自动装配和精确装配

    8.2.6 Spring 4.0 增强的自动装配和精确装配 Spring提供了@Autowired 注解来指定自动装配,@Autowired可以修饰setter方法.普通方法.实例变量和构造器等.当使 ...

  9. Kafka consumer group位移重设

    本文阐述如何使用Kafka自带的kafka-consumer-groups.sh脚本随意设置消费者组(consumer group)的位移.需要特别强调的是, 这是0.11.0.0版本提供的新功能且只 ...

  10. linux系统抓包命令

    IP地址抓包:tcpdump -i any host 1.1.1.2 -n 端口抓包: tcpdump -i any port 6789 -n wireshak工具抓包:tcp.port == 678 ...