free() - VxWorks

This is a discussion on free() - VxWorks ; Hi Groups, What happens if the function free() gets an address that is not returned by malloc() etc. Thanks and Regards Karthik Raghavendran . R...

+ Reply to Thread
Results 1 to 3 of 3

Thread: free()

  1. free()

    Hi Groups,

    What happens if the function free() gets an address that is not
    returned by malloc() etc.

    Thanks and Regards
    Karthik Raghavendran . R

  2. Re: free()

    On Dec 19, 10:19 am, karthikr...@gmail.com wrote:
    > Hi Groups,
    >
    > What happens if the function free() gets an address that is not
    > returned by malloc() etc.
    >
    > Thanks and Regards
    > Karthik Raghavendran . R


    Hi,

    depending upon ED&R policy error will be reported followed by
    taskSuspend (99% of the time). Why I am saying 99% is because it
    depends upon the address passed to free(). A header is extracted from
    the pointer passed to it and if system is able to determine that this
    pointer does not belong to the right block the procedure I said should
    be followed; however what values header have will really depend upon
    the address passed to it.

    Best Regards
    VKG | Ritsoft Technologies

  3. Re: free()

    karthikragh@gmail.com wrote:
    > Hi Groups,
    >
    > What happens if the function free() gets an address that is not
    > returned by malloc() etc.


    Almost anything, and it'll likely be very hard to diagnose. A memory
    smash might result, as free() tries to link the fake area onto its
    available list. The very nicest result I can think of, is the avail-
    able list will get corrupted, leading to malloc handing out invalid
    area addresses sometime later, which will likely also lead to a memory
    smash.

    It depends on what the address points to, that you pass to free().
    Imagine that it's a code address....

    It's worth a lot of care to avoid this situation, 'cause it's so hard
    to debug. There are debugging versions of the malloc/free library,
    and you'd have to integrate them into vxWorks yourself. Again, a lot
    of work.

    >
    > Thanks and Regards
    > Karthik Raghavendran . R


+ Reply to Thread