heap-corruption

Invalid write size of 4 with matrix class (using valgrind)

强颜欢笑 提交于 2019-12-11 05:29:16
问题 I have a simple matrix class I've made for use with opengl (es 2.0, afaik there isn't any built in version for that particular version of opengl). It is basically nothing more than a vector which is resized to contain 16 floats in the constructor, (I chose a vector over just a 16 float array for the = operator it had), and some convenience functions that are useful in the context of opengl. Anyway, one of these convenience structures loads the identity matrix into the vector, it is: void

Finding heap corruption

北战南征 提交于 2019-12-11 03:23:42
问题 This is an extension of my previous question, Application crash with no explanation. I have a lot of crashes that are presumably caused by heap corruption on an application server. These crashes only occur in production; they cannot be reproduced in a test environment. I'm looking for a way to track down these crashes. Application Verifier was suggested, and it would be fine, but it's unusable with our production server. When we try to start it in production with application verifier, it

Is it valid to pass a pointer to a stack variable to realloc()?

北城余情 提交于 2019-12-10 17:28:08
问题 int main() { char myString = NULL; realloc(&myString, 5); strncpy((char *)&myString, "test", 5); } Seems to work fine but I'm still slightly confused about stack vs heap. Is this allowed? If it is allowed, does myString need to be freed manually or will it be released when it goes out of scope? Edit: Thanks for the responses, so i presume this is equally illegal //I want the code to change myString to "tests" char myString[5] = "test"; realloc(&myString, strlen(myString)+2); myString[4] = 's'

Critical error detected c0000374 - C++ dll returns pointer off allocated memory to C#

只愿长相守 提交于 2019-12-10 02:47:51
问题 I have a c++ dll which serving some functionality to my main c# application. Here i try to read a file, load it to memory and then return some information such as the Pointer to loaded data and count of memory blocks to c#. The Dll reads file to memory successfully but on the return to the main application, program crashes due to Heap Corruption(Critical error detected c0000374). The code is quite simple and straightforward and I have done some similar things before with no problem, However i

Heap corruption when returning from function inside a dll

馋奶兔 提交于 2019-12-04 22:45:31
问题 I have a function with a prototype like the following: void function(std::string str); This function is called in my main function in another program that loads and uses that dll. function("some string value here"); When returning from this function I get heap corruption error: Windows has triggered a breakpoint in program.exe. This may be due to a corruption of the heap, which indicates a bug in program.exe or any of the DLLs it has loaded. This may also be due to the user pressing F12 while

.NET 4: Can the managed code alone cause a heap corruption?

不羁岁月 提交于 2019-12-04 01:33:22
I have a heap corruption in my multi-threaded managed program. Doing some tests I found that the corruption happens only when the background threads active in the program (they are switchable). The threads use some 3rd party components. After examining the code of the threads and 3rd party components (with .NET Reflector) I found that they are all managed, i.e. no "unsafe" or "DllImportAttribute" or "P/Invoke". It seems that the purely managed code causes a heap corruption, is this possible? UPDATE Apart from using Marshal class, is it possible to corrupt the heap with threads not being

How to use Microsoft Application Verifier

亡梦爱人 提交于 2019-12-03 19:44:34
问题 Using C++ and discovered today during a demo that I'm suffering from a corrupted heap (but only on important occasions!!). I found a few posts here on SO and decided to download Application Verifier and Debugging tool. I am current running Visual Studio 2010. So, now I'm left with an installtion of the the debugging tool where I get a folder called Windows Kits. In the folder I have an app called WinDbg where I tried to open my app and run it. It worked fined but I was not able to get any

Heap corruption when returning from function inside a dll

被刻印的时光 ゝ 提交于 2019-12-03 13:25:39
I have a function with a prototype like the following: void function(std::string str); This function is called in my main function in another program that loads and uses that dll. function("some string value here"); When returning from this function I get heap corruption error: Windows has triggered a breakpoint in program.exe. This may be due to a corruption of the heap, which indicates a bug in program.exe or any of the DLLs it has loaded. This may also be due to the user pressing F12 while program.exe has focus. The output window may have more diagnostic information. Playing around with my

Program do not crash on heap overflow

夙愿已清 提交于 2019-12-02 23:39:43
问题 I have written following program: #include <stdio.h> #include <string.h> #include <stdlib.h> void main(int argc, char *argv[]){ char *input; input = (char*)malloc(16); printf("input is : %s\n", input); } When I run this as: ./test `python -c 'print "A"*5000'` it does not crash. It rather prints data. When I use free(input) after printf , it crashes. Why does this happen? 回答1: The code shown ignores its command line arguments: int main(int argc, char *argv[]){ char *input; input = (char*

Dynamically allocating new object in constructor

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 06:12:34
问题 So given this simple scenario: class A{ public: A(){ n = new int(10); } ~A(){ delete n; } int* n; }; int main(){ A* a = new A(); } Can this cause heap corruption (problems in general), since a-pointer hasn't finished allocating, while I'm making a new allocation? If so, using std::vector inside heap constructors in also prohibited, right? Thank you. 回答1: Your a pointer has finished allocating . New works as follows (oversimplified) Allocate Construct So in your case Allocate A Construct A