Re: [cc65] Why crashing attempting to free this struct?

From: Oliver Schmidt <ol.sc1web.de>
Date: 2012-03-25 10:48:55
Hi Payton,

> I get a CPU jam whenever I attempt to free an instance of DirectoryListReuBlock.  I've got no idea what's causing this, but they have to be freed or I'll have memory leaks galore.
>
>
The "nice" thing about heap programming is that the root cause of such an
issue might be in about every place of your program that handles pointers.
The usual way to find out if this is the case is:

1. printf() the pointer right after malloc() and right before free() and
check for identity.

2. Get some knowledge about the internal heap structures. I already did
this for you ;-) Below is a sentence from a comment in _heapblocksize.s:

"Below the user data is a pointer that points to the start of the
real (raw) memory block. The first word of this block is the size."

So do the following again right after malloc() and before free() and check
for identity:

2.a Decrease your pointer by two bytes and printf() two bytes found there.
2.b Interpret those two bytes as pointer and printf() two bytes at the
location it points to.

Regards,
Oliver

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sun Mar 25 10:50:50 2012

This archive was generated by hypermail 2.1.8 : 2012-03-25 10:50:54 CEST