Unix/Linux Go Back    


Programming Post questions about C, C++, Java, SQL, and other programming languages here.

Mismatched free() / delete / delete [] line no missing

Programming


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 11-07-2016
SA_Palani SA_Palani is offline
Registered User
 
Join Date: Aug 2016
Last Activity: 21 February 2017, 11:01 AM EST
Posts: 24
Thanks: 2
Thanked 0 Times in 0 Posts
Mismatched free() / delete / delete [] line no missing

Could you tell me the possibilities of the reason to get the Mismatched free() / delete / delete [].

I unable to see the line no in the valgrind report. it displays the function name. with that function name, I am not able to find where exactly the issue is there.I am getting the Mismatched free() / delete / delete [].


Thanks in Advance.

Last edited by rbatte1; 11-07-2016 at 06:11 AM.. Reason: Added ICODE tags for the error message and corrected spelling
Sponsored Links
    #2  
Old Unix and Linux 11-07-2016
Don Cragun's Unix or Linux Image
Don Cragun Don Cragun is online now Forum Staff  
Administrator
 
Join Date: Jul 2012
Last Activity: 24 February 2017, 2:50 AM EST
Location: San Jose, CA, USA
Posts: 10,017
Thanks: 484
Thanked 3,454 Times in 2,949 Posts
Without knowing what language you're using, anything about what your code looks like, nor what error is actually being reported by valgrind, about all that we can say is that you are probably trying to free an area of memory that you allocated at some point in the past and corrupted part of the region of memory that your memory allocation library uses to keep track of its memory pool OR you are trying to free memory that was never allocated.

Without more information, every assignment statement in your code is suspect, every return statement in your code is suspect, and every reference to every object that is a pointer in your code is suspect.
Sponsored Links
    #3  
Old Unix and Linux 11-07-2016
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 23 February 2017, 4:37 PM EST
Location: Aachen, Germany
Posts: 10,329
Thanks: 244
Thanked 3,153 Times in 2,918 Posts
Weren't the explanations in your other thread sufficient? Can't you debug your programme, or, at least, print out the contents of the variables (pointers) in question?
    #4  
Old Unix and Linux 11-07-2016
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 23 February 2017, 9:51 PM EST
Location: Saskatchewan
Posts: 21,934
Thanks: 1,050
Thanked 4,099 Times in 3,798 Posts
Quote:
Originally Posted by SA_Palani View Post
Could you tell me the possibilities of the reason to get the Mismatched free() / delete / delete [].
From your other thread, you are doing this:

Code:
char *mem=new char;
mem=NULL;
delete mem;

You can't delete NULL. You can only delete a value given to you by new. That's why it crashes.

valgrind is not magic, and the value of the pointer is literally all valgrind, or new / delete, track. If you feed it an invalid pointer, such as NULL, it won't be able to make sense of it.

Duplicate thread closed.

Last edited by Corona688; 11-07-2016 at 06:29 PM..
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Mismatch free() / delete / delete [C++] SA_Palani Linux 7 11-04-2016 12:14 PM
Script needed to delete to the list of files in a directory based on last created & delete them prasadn Shell Programming and Scripting 2 03-02-2015 09:01 AM
Delete data blocks based on missing combinations senhia83 UNIX for Dummies Questions & Answers 6 11-05-2014 03:34 PM
Compare files in two folders and delete missing ones kaah Shell Programming and Scripting 20 03-03-2010 12:07 PM
How do you delete files that are seemingly missing inodes? jaffachamp UNIX for Dummies Questions & Answers 5 02-02-2009 09:42 PM



All times are GMT -4. The time now is 04:00 AM.