memory-corruption

Why does this code corrupt memory?

This is a fairly newbie question which should be answerable reasonably quickly... Basically, after the first call to Printf in echo, the contents of args is corrupted. It sounds to me like i'm passing the pointers around incorrectly. But can't figure out why? #define MAX_PRINT_OUTPUT 4096 void Echo(char *args[MAX_COMMAND_ARGUMENTS], i...

Perplexing STL bug in Release in Visual Studio.

I have what I'm pretty sure is a bug in the optimizer in Visual studio 2005. The problem is with an STL map. Here's the relevant code: MyMapIterator myIt = m_myMap.find(otherID); if (myIt != m_myMap.end() && myIt->second.userStatus == STATUS_A) { //Prints stuff. No side-effects whatsoever. } else if (myIt != m_myMap.end() && myIt->...

FastMM4 says "The block header has been corrupted"

Hi. 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 fr...

void pointers and ffcall library

I'm using the ffcall (specifically the avcall package of ffcall) library to dynamically push parameters to variadic functions. i.e. we have int blah (char *a, int b, double c, ...); and we want to call this function with values taken from the user. To do this, we create an avcall version of the function: int av_blah (char *a, int b...

summary: malloc.c:3074 - Why does this code causes the error

The attached below C code when run gives the error summary: malloc.c:3074: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+...

What is the right tool to detect VMT or heap corruption in Delphi ?

I'm a member in a team that use Delphi 2007 for a larger application and we suspect heap corruption because sometimes there are strange bugs that have no other explanation. I believe that the Rangechecking option for the compiler is only for arrays. I want a tool that give an exception or log when there is a write on a memory address th...

C++ vector push_back() overwrites on another vector of the same type?

I defined a class named nth_best_parse this way: class nth_best_parse { public: int traversal; int nth_best_active; int nth_best_passive; double viterbi_prob; nth_best_parse(); nth_best_parse(int t, int nbl, int nbr, double v) {traversal = t; nth_best_active = nbl; nth_best_passive ...

string overflow detection in C

We are using DevPartners boundchecker for detecting memory leak issues. It is doing a wonderful job, though it does not find string overflows like the following char szTest [1] = ""; for (i = 0; i < 100; i ++) { strcat (szTest, "hi"); } Question-1: Is their any way, I can make BoundsChecker to detect this? Question-2: Is their ...

std::string constructor corrupts pointer

I have an Entity class, which contains 3 pointers: m_rigidBody, m_entity, and m_parent. Somewhere in Entity::setModel(std::string model), it's crashing. Apparently, this is caused by bad data in m_entity. The weird thing is that I nulled it in the constructor and haven't touched it since then. I debugged it and put a watchpoint on it, an...

C++ -malign-double compiler flag

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 r...

Can you force a crash if a write occurs to a given memory location with finer than page granularity?

I'm writing a program that for performance reasons uses shared memory (sockets and pipes as alternatives have been evaluated, and they are not fast enough for my task, generally speaking any IPC method that involves copies is too slow). In the shared memory region I am writing many structs of a fixed size. There is one program responsibl...

How to log when a particular memory location gets written and by which function?

I have a bug which happens very rarely but crashes my C++ program. It's seems I have a buffer overflow problem or something similar. I find that these types of bug are the most difficult to diagnose. My program always crashes because of the same corrupted memory location. Is there some debugging tool which could detect when a particular...

Corruption of static variable from unrelated library object (and vice versa)

I have a small VC++ application, in two pieces. The first piece contains the main functionality and is compiled as a static library. The second piece is a windows service that links to the library from piece one. I'm seeing some odd behavior caused by memory corruption. By setting data breakpoints and the like, I was able to determine...

glibc Heap Consistency Checking

According to posts from 2008 (I can't find it right now), glibc heap check doesn't work in multithreaded environment. Is it still situation now in 2010? Does heap check enabled by default? (gcc 4.1.2)? I don't set MALLOC_CHECK_, don't aware of calling mcheck(), but still sometimes receive double free glibc error with backtrace. Maybe it...

Why do I get this strange output behavior?

I have the following program test.cc: #include <iostream> unsigned char bogus1[] = { // Changing # of periods (0x2e) changes output after periods. 0x2e, 0x2e, 0x2e, 0x2e }; unsigned int bogus2 = 1816; // Changing this value changes output. int main() { std::clog << bogus1; } I build it with: g++ -g -c -o test.o test.cc; g++ -s...

Methods/Tools for solving a Mystery Segfault while running on condor

I'm writing a C application which is run across a compute cluster (using condor). I've tried many methods to reveal the offending code but to no avail. Clues: On Average when I run the code on 15 machines for 2 days, I get two or three segfaults (signal 11). When I run the code locally I do not get a segfault. I ran it for nearly 3 we...

Corrupted memory. SQLite or Android bug...

I get such stack trace: android.database.sqlite.SQLiteException: no such table: someTa???: , while compiling: SELECT COUNT(*) FROM someTa??? WHERE a = ? AND b = ? at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method) at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91) at andro...