草庐IT

memory-corruption

全部标签

c++ - 解决错误: Stack around the variable 'x' was corrupted的一般方法

我有一个程序在调试时提示我VS2010中的错误:Error:Stackaroundthevariable'x'wascorrupted这为我提供了可能发生堆栈溢出的函数,但我无法直观地看到问题出在哪里。有没有用VS2010调试这个错误的通用方法?是否有可能确定哪个写操作覆盖了不正确的堆栈内存?谢谢 最佳答案 IsthereageneralwaytodebugthiserrorwithVS2010?不,没有。您所做的是以某种方式调用未定义的行为。这些行为未定义的原因是一般情况很难检测/诊断。有时证明是不可能的。但是,通常会导致您的问题

c++ - Error1 错误 LNK1107 : invalid or corrupt file: cannot read at 0x2B0

我是opengl的新手,我不知道这个错误是什么意思。我正在使用VisualStudio2012>C++>空项目。我在其他适合我的电脑上按照这些步骤操作,但我在我的电脑上执行此操作时出现此错误。ERRORError1errorLNK1107:invalidorcorruptfile:cannotreadat0x2B0?>C:\Users\Uxi\Desktop\Sp16\Vs\OpenglPrac\OpenglPrac\glew32.dll11>OpenglPrac我遵循的步骤是:将文件夹Glew和Glut从我的文件夹复制到您的桌面。打开VisualStudio,选择新建项目选择Visu

c++ - Error1 错误 LNK1107 : invalid or corrupt file: cannot read at 0x2B0

我是opengl的新手,我不知道这个错误是什么意思。我正在使用VisualStudio2012>C++>空项目。我在其他适合我的电脑上按照这些步骤操作,但我在我的电脑上执行此操作时出现此错误。ERRORError1errorLNK1107:invalidorcorruptfile:cannotreadat0x2B0?>C:\Users\Uxi\Desktop\Sp16\Vs\OpenglPrac\OpenglPrac\glew32.dll11>OpenglPrac我遵循的步骤是:将文件夹Glew和Glut从我的文件夹复制到您的桌面。打开VisualStudio,选择新建项目选择Visu

C++ boost库shared_memory_object undefined reference 'shm_open'

我尝试在ubuntu11.04上编译以下代码:#include#includeintmain(){boost::interprocess::shared_memory_objectshdmem(boost::interprocess::open_or_create,"Highscore",boost::interprocess::read_write);shdmem.truncate(1024);std::cout只得到以下错误:/tmp/cc786obC.o:Infunction`boost::interprocess::shared_memory_object::priv_open

C++ boost库shared_memory_object undefined reference 'shm_open'

我尝试在ubuntu11.04上编译以下代码:#include#includeintmain(){boost::interprocess::shared_memory_objectshdmem(boost::interprocess::open_or_create,"Highscore",boost::interprocess::read_write);shdmem.truncate(1024);std::cout只得到以下错误:/tmp/cc786obC.o:Infunction`boost::interprocess::shared_memory_object::priv_open

c++ - Valgrind 几乎对所有内容都给出错误(警告 : client switching stacks?)

我以某种方式破坏了内存,因为我的程序在随机位置崩溃而没有错误。我正在使用带有--leak-check=full的valgrind,使用-O0-g进行编译,它检测到的第一个问题是intmain()cout与==5089==Warning:clientswitchingstacks?SPchange:0x7ff0004f8-->0x7feb7de10==5089==tosuppress,use:--max-stackframe=4728552orgreater==5089==Invalidwriteofsize8==5089==at0x41E107:main(Dgn.cpp:2833)==

c++ - Valgrind 几乎对所有内容都给出错误(警告 : client switching stacks?)

我以某种方式破坏了内存,因为我的程序在随机位置崩溃而没有错误。我正在使用带有--leak-check=full的valgrind,使用-O0-g进行编译,它检测到的第一个问题是intmain()cout与==5089==Warning:clientswitchingstacks?SPchange:0x7ff0004f8-->0x7feb7de10==5089==tosuppress,use:--max-stackframe=4728552orgreater==5089==Invalidwriteofsize8==5089==at0x41E107:main(Dgn.cpp:2833)==

c++ - 虚拟析构函数 : is it required when not dynamically allocated memory?

如果我的类不动态分配任何内存,我们是否需要虚拟析构函数?例如classA{private:inta;intb;public:A();~A();};classB:publicA{private:intc;intd;public:B();~B();};在这种情况下,我们需要将A的析构函数标记为虚拟吗? 最佳答案 问题不在于您的类是否动态分配内存。如果类的用户通过A指针分配B对象,然后将其删除:A*a=newB;deletea;在这种情况下,如果A没有虚拟析构函数,C++标准会说您的程序表现出未定义的行为。这可不是什么好事。此行为在标准的

c++ - 虚拟析构函数 : is it required when not dynamically allocated memory?

如果我的类不动态分配任何内存,我们是否需要虚拟析构函数?例如classA{private:inta;intb;public:A();~A();};classB:publicA{private:intc;intd;public:B();~B();};在这种情况下,我们需要将A的析构函数标记为虚拟吗? 最佳答案 问题不在于您的类是否动态分配内存。如果类的用户通过A指针分配B对象,然后将其删除:A*a=newB;deletea;在这种情况下,如果A没有虚拟析构函数,C++标准会说您的程序表现出未定义的行为。这可不是什么好事。此行为在标准的

c++ - Linux乐观malloc : will new always throw when out of memory?

我一直在阅读有关Linux内存不足的情况,手册页中的以下段落让我思考:Bydefault,Linuxfollowsanoptimisticmemoryallocationstrategy.Thismeansthatwhenmalloc()returnsnon-NULLthereisnoguaranteethatthememoryreallyisavailable.Thisisareallybadbug.Incaseitturnsoutthatthesystemisoutofmemory,oneormoreprocesseswillbekilledbytheinfamousOOMkill