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 05: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 offline Forum Staff  
Administrator
 
Join Date: Jul 2012
Last Activity: 20 September 2017, 2:57 AM EDT
Location: San Jose, CA, USA
Posts: 10,502
Thanks: 542
Thanked 3,675 Times in 3,135 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 online now Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 20 September 2017, 3:24 AM EDT
Location: Aachen, Germany
Posts: 11,346
Thanks: 297
Thanked 3,521 Times in 3,240 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: 19 September 2017, 5:41 PM EDT
Location: Saskatchewan
Posts: 22,391
Thanks: 1,126
Thanked 4,230 Times in 3,911 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 05: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 11:14 AM
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 08:01 AM
Delete data blocks based on missing combinations senhia83 UNIX for Dummies Questions & Answers 6 11-05-2014 02:34 PM
Compare files in two folders and delete missing ones kaah Shell Programming and Scripting 20 03-03-2010 11:07 AM
How do you delete files that are seemingly missing inodes? jaffachamp UNIX for Dummies Questions & Answers 5 02-02-2009 08:42 PM



All times are GMT -4. The time now is 03:28 AM.