memory-corruption

FastMM4 says “The block header has been corrupted”

拥有回忆 提交于 2019-12-03 13:44:44
问题 I had this nasty bug that disappeared in the past but now after quite some time it returned. I have two TSam objects (derived from TPersistent) created and loaded into an TAsmJob object (derived from TObjectList). At runtime, a form creates a TStringGrid and then the AsmJob which creates those two SAM objects (and load some data from disk in each of them). The AsmJob is also assigned to the grid. When the form is destroyed, the Grid takes care of the AsmJob by freeing it, which frees the TSam

FastMM4 says “The block header has been corrupted”

╄→尐↘猪︶ㄣ 提交于 2019-12-03 03:44:53
I had this nasty bug that disappeared in the past but now after quite some time it returned. I have two TSam objects (derived from TPersistent) created and loaded into an TAsmJob object (derived from TObjectList). At runtime, a form creates a TStringGrid and then the AsmJob which creates those two SAM objects (and load some data from disk in each of them). The AsmJob is also assigned to the grid. When the form is destroyed, the Grid takes care of the AsmJob by freeing it, which frees the TSam objects. Here is the problem: the first object is freed withot problems but the second one dies when

C++ -malign-double compiler flag

心不动则不痛 提交于 2019-12-01 20:52:13
问题 I need some help on compiler flags in c++. I'm using a library that is a port to linux from windows, that has to be compiled with the -malign-double flag, "for Win32 compatibility". It's my understanding that this mean I absolutely have to compile my own code with this flag as well? How about other .so shared libraries, do they have be recompiled with this flag as well? If so, is there any way around this? I'm a linux newbie (and c++), so even though I tried to recompile all the libraries I'm

boost::spirit::hold_any memory corruption

試著忘記壹切 提交于 2019-12-01 01:03:26
I have a large code base that can use boost::any or boost::spirit::hold_any (depending on a macro definition). hold_any seems to be compatible with boost::any (e.g. How to print boost::any to a stream? or Type erasure - Part IV ) and faster ( Why you shouldn’t use boost::any ) but I'm experiencing several segmentation fault errors using hold_any (Boost v1.55 / 1.54 / 1.53). This is a minimal working example that exhibits the same problem as the original code: #include <iostream> #include <string> #include <vector> #include <boost/spirit/home/support/detail/hold_any.hpp> typedef boost::spirit:

Heap corruption not detected by Valgrind or Electric Fence. Should I be suspicious? (C++)

女生的网名这么多〃 提交于 2019-11-30 14:30:56
I recently encountered my first battle (solved) with heap corruption. On my linux machine at home the culprit code exits without error using valgrind and electric-fence(with gdb). Yet on the windows machine in our lab, I consistently get the heap corruption related error message from VS described in my referenced post. Is it surprising (or at least uncommon) that valgrind and electric fence wouldn't detect such a problem? Someone else mentioned a possibly similar bug that eluded valgrind in a answer here . What might be some reasons why this problem wouldn't be detected by these tools? Is

Heap corruption not detected by Valgrind or Electric Fence. Should I be suspicious? (C++)

泪湿孤枕 提交于 2019-11-29 20:27:20
问题 I recently encountered my first battle (solved) with heap corruption. On my linux machine at home the culprit code exits without error using valgrind and electric-fence(with gdb). Yet on the windows machine in our lab, I consistently get the heap corruption related error message from VS described in my referenced post. Is it surprising (or at least uncommon) that valgrind and electric fence wouldn't detect such a problem? Someone else mentioned a possibly similar bug that eluded valgrind in a

Having hard time tracking memory corruption - when running with Valgrind runs correctly with no errors

我的梦境 提交于 2019-11-29 07:38:00
We have a complex program that is working well on heavy duty input (any input actually) with no multithreading implemented. We've implemented multithreading with a threadpool, and given these input parameters I get these results: ( Note : Where I say no errors , it means I've tested with valgrind -v and when I say no memory leaks , it means I've tested it with valgrind --leak-check=full -v ). small_file: Runs successfully with more than 1 workers (threads), no valgrind errors, no memory leaks medium_file: With 1 worker it runs successfully, no errors/memory leaks. With > 1 workers, I get: a.

Writing to pointer out of bounds after malloc() not causing error

£可爱£侵袭症+ 提交于 2019-11-26 18:00:45
when I try the code below it works fine. Am I missing something? main() { int *p; p=malloc(sizeof(int)); printf("size of p=%d\n",sizeof(p)); p[500]=999999; printf("p[0]=%d",p[500]); return 0; } I tried it with malloc(0*sizeof(int)) or anything but it works just fine. The program only crashes when I don't use malloc at all. So even if I allocate 0 memory for the array p, it still stores values properly. So why am I even bothering with malloc then? It might appear to work fine, but it isn't very safe at all. By writing data outside the allocated block of memory you are overwriting some data you

Writing to pointer out of bounds after malloc() not causing error

坚强是说给别人听的谎言 提交于 2019-11-26 04:28:30
问题 when I try the code below it works fine. Am I missing something? main() { int *p; p=malloc(sizeof(int)); printf(\"size of p=%d\\n\",sizeof(p)); p[500]=999999; printf(\"p[0]=%d\",p[500]); return 0; } I tried it with malloc(0*sizeof(int)) or anything but it works just fine. The program only crashes when I don\'t use malloc at all. So even if I allocate 0 memory for the array p, it still stores values properly. So why am I even bothering with malloc then? 回答1: It might appear to work fine, but