From: j DOT aldrich6 AT genie DOT com Message-Id: <199604230019.AA055928794@relay1.geis.com> Date: Tue, 23 Apr 96 00:09:00 UTC 0000 To: djgpp AT delorie DOT com Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Subject: Unexplained memory problems Hi folks. This is not so much a DJGPP question as a plea for assistance with a problem that has really been bugging me... I have been getting some extremely odd and seemingly random crashes with a large program I've been modifying. It maintains a number of large linked lists that seem to be getting corrupted for an unknown reason. The problem manifests itself when I attempt to traverse the list using a standard loop, like so: for ( d = descriptor_list; d != NULL; d = d_next ) { d_next = d->next; ... } The crash is a SIGSEGV on the line that says 'd_next = d->next'. This is only an example - there are many loops of this kind, working with several different linked lists, and the crash seems to pop up spontaneously in any one of them, but it is universally AFTER I have tested the pointer for a NULL value. In order to isolate the cause of the problem, I recompiled the program with _CRT0_FLAG_FILL_DEADBEEF set. What showed up during debugging is one of the oddest things Ihave ever seen. After one such crash, I told gdb to display the contents of the head pointer to the list, and all the values of the structure were 'deadbeef'! The pointer was pointing to the right place, but somehow everything in that area of memory got overwritten with uninitialized memory! Cross-checking proved that the value of the pointer hadn't been changed. Is this something that a bug in my program could conceivably cause? I'm not fooling around with DPMI calls or locking memory or anything like that, and the areas of memory that the pointers are referencing are allocated via calloc() from the heap. They should be safe from stack overflows, right? And how, regardless of what my program has done, could the memory be being 'reinitialized'? I'm pretty sure I'm not accidentally freeing the memory. Thanks in advance for any tips you might have... John