Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 09-12-2014, 02:43 PM   #1
LQ Newbie
Registered: Sep 2014
Posts: 2

Rep: Reputation: Disabled
Question program aborted while freeing variable from memory

when debugging my program i receive this error from GDB

Program received signal SIGABRT, Aborted.

it happens at this line in my code

free((int *)ptr);

ptr is a void pointer that is indeed pointing to an integer. stepping through the program i find that even at this line (immediately proceeding it's execution) the pointer value can still be read correctly with explore value (int *)ptr. I have also checked to make sure that ptr was not accidentally set to the position of a variable actually declared in my program and i found that it was not. I am completely stumped at this point any help would be very appreciated.
Old 09-12-2014, 03:40 PM   #2
LQ Newbie
Registered: Sep 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
I found the culprit

int in = (*blockPtr).count;
for(;in > (*blockPtr).count - l + index; in--)
((void **)(*blockPtr).array)[in] = ((void **)(*blockPtr).array)[in-1];

here i shift all elements to the right in a non-full array that fall past a target index within that array.
However, i left out the following line which is meant to assign the target index with a new pointer value in order to perform an "insertion" operation.

((void **)(*blockPtr).array)[in] = newptr;

since i did not reassign that index, i had two indices pointing to the same position in memory which caused me to double free a spot in memory. Hopefully my mistake will help someone else fix theirs.

Last edited by trapfether; 09-12-2014 at 03:41 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot allocate memory Aborted problem while executing thread program in ARM9 board biyabani Linux - Newbie 0 07-18-2013 01:44 PM
Freeing Up Used Memory zoso Linux - Newbie 7 01-11-2005 10:44 PM
Allocating memory for user program variable from kernel module appas Programming 2 08-12-2004 11:52 PM
freeing memory in linux har5ha Linux - Software 7 07-23-2004 06:00 PM
Freeing up Memory DigiCrime Linux - General 5 09-30-2003 08:25 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:58 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration