This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Code goes into free() and crashes

Other Parts Discussed in Thread: TMS320C6748

Hello has anyone ever seen this before on the C6748. My code crashes while trying to free up a memory blcok that

was previously allocated from heap. I confirmed  that the pointer was valid and correct at the time of making the call.  While single stepping it goes into free ()and never returns

I am using the TMS320C6748 LCDK evaluation board., Has anyoen seen this before

  • Tosin Osinusi,

    Welcome to the TI E2E forum. I hope you will find many good answers here and in the TI.com documents and in the TI Wiki Pages. Be sure to search those for helpful information and to browse for the questions others may have asked on similar topics.

    There are quite a few different forums on E2E. This device forum is good for device-specific or hardware/driver questions. The C/C++ Compiler Forum is good for issues with the build tools and the Run-Time Support library. The Code Composer Forum is good for issues with the debugger and its capabilities.

    Honestly, I have had lots of problems like this. I have had linked lists that I forgot to close off with a NULL at the end. I have had pointers that I moved through an array and then tried to free() them. I have used the same variable name in different contexts and did not realize I was using a different variable by the same name.

    It is very unlikely that you have uncovered a bug in the free() function. It has been used by many customers and TIers for many years.

    The easiest issue to look at, and not have to look for a code problem, is to increase the size of the stack and see if that fixes the problem. Next, increase the size of the heap and see if that fixes the problem.

    But after that, you will need to use your skill at debugging your code to find the problem. Please let us know what kinds of debug steps you have taken and what results you have found. Let us know how it goes and what you learn about it.

    Regards,
    RandyP

  • Hello Randy,

    I would certainly agree that it is unlikely to be a problem wtih free() itself. I was thinking it might be a problem with code compose studio.

    I will take a look on the code composer forums. I have tried increasing the stack and heap. They are both way oversized at this point.

     

    Thanks for the quick reply.

  • Tosin,

    I am not sure what you would expect to be failing in CCS. But one technique you can use is to set a breakpoint on the instruction after the call to free(), and then Run/Resume instead of single-stepping over the free() call. If that works, then you might have a reason to look into CCS.

    You can use the C source for free() by pulling the MEMORY.C file out of the rtssrc.zip file from the compiler's folder on your PC. If you add that to your project, then you can use source-level debugging to find out where free() is getting stuck.

    Regards,
    RandyP

  • Randy,

     

    You were right. It was something very simple. One of the previous mallocs was the wrong size.

    Basically I malloc'ed 1K when I needed a 2K buffer. I am sure you can think of a million ways how that

    could screw up the heap.

    Thanks for you help.

  • Tosin,

    Good debug work. Thanks for letting us know.

    We have all been there.

    Regards,
    RandyP