malloc:what can "corrupt" allocated memory in Linux/Qt application (threads involved)? <p><em>Dirty hacks at 05:00 AM. I have sinned, SO</em>, by passing pointer's address between same process's threads with FIFO:</p> <pre><code>total_buf = (char*)malloc(msize); // ... long addr = (long)&amp;total_buf; // ... write(fifo, buf, 128); </code></pre> <p>After receiving pointer to total_buf in receiver thread, <code>void* pt = (void*)addr;char* tbuf = (char*)pt;</code> I noticed that buffer content changed, and that was clearly confirmed by examining memory content: <code>(gdb) x/1024xb tbuf</code>.</p> <p>What are possible reasons for this to happen - in a context of multithreaded Qt+pure pthreads application's plugins trying to communicate directly? For some reason, I feel it's not some obvious garbage collection and afair, Linux threads are using shared process memory, so it's no address mismatch, and the pointer dereference looks alright too,.</p>