• Register
0 votes
2.1k views

Problem :

I am facing the following error :

malloc: *** error for object 0xa68aca0: pointer being freed was not allocated

*** set a breakpoint in malloc_error_break to debug

I have already set the Symbolic Breakpoint, Still Nothing happens on the console, Not getting any hint from the console.

I am having xcode 4.6

Does anybody have any clue about the error?

6 5 3
7,540 points

Please log in or register to answer this question.

2 Answers

0 votes

Solution :

I have lots of industry experience in writing complex code.

I have gone through your post and understood your problem.

So to begin with you must follow below approach to resolve your issue:.

I think you are releasing the object too many times.

So to solve this please open up your debugger console by pressing combination of Cmd+Shift+R. and after doing that please type in the following code:

break malloc_error_break

Above mentioned code will set a breakpoint at the beginning of your malloc_error_break, After doing that you can also try to do print out and understand what is the object at 0xa68aca0 by using following code.

print-object 0x1068310

9 7 4
38,600 points
0 votes

Solution:

The issue is with this code:

parent.left = &a;
parent.right = &b;

This is getting pointers to local variables, which will be reinitialized next time on all direction the loop. CharCountNode will al last attempt to delete these objects, however they haven't been allocated by new.

You require to make left and right point to objects allocated on the heap, as that is what CharCountNode is expecting. Something like:

parent.left = new CharCountNode(a);
parent.right = new CharCountNode(b);

You require to include this to just earlier on return dataReturn; in your dataTest function:

dataReturn[i] = NULL ;

Else your while (data[i]) {} will continue further than wanted.

And instead of:

dataReturn[i] = malloc( sizeof(char) * (strlen(*str)) );

write:

dataReturn[i] = malloc(strlen(*str) + 1);

With a view to allocating space for the terminating zero.

BTW sizeof (char) is always 1.

python 3.6 malloc: pointer being freed was not allocated / set a breakpoint in malloc_error_break to debug Abort trap: 6

 

10 6 4
31,120 points

Related questions

0 votes
1 answer 24 views
24 views
Problem: I am facing the following error : Pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug .
asked Mar 14 Wafa Abu Yousef 6.1k points
0 votes
1 answer 40 views
0 votes
1 answer 67 views
67 views
Problem: I'm doing some homework for an OOP class and I've been stuck for a good hour now. I'm getting this error once I've used keyboard input enough. I am not someone who gets frustrated at all, and here I am getting very frustrated with this.
asked Dec 13, 2020 Mashhoodch 13k points
0 votes
1 answer 6 views
6 views
Problem: Please can anyone tell me the right procedure to do it?*** set a breakpoint in malloc_error_break to debug
asked Apr 19 Ifra 36.4k points
0 votes
1 answer 6 views
6 views
Problem: I'm getting lots of console outputs like this without my application crashing: malloc: * error for object 0xc6a3970: pointer being freed was not allocated * set a breakpoint in malloc_error_break to debug How can I find out which object or variable is affected?
asked Mar 24 ummesalma 29.2k points
0 votes
1 answer 1 view
1 view
Problem: I need someone’s assistance to solve my problem .. This breakpoint will not currently be hit
asked 1 day ago Ifra 36.4k points
0 votes
1 answer 6 views
6 views
Problem: itunes was unable to load dataclass information from sync services.
asked Feb 13 Sabbir Hossain 14.6k points
0 votes
1 answer 28 views
28 views
Problem: Just started using Xcode 4.5 and I got this error in the console: Warning: Attempt to present < finishViewController: 0x1e56e0a0 > on < ViewController: 0x1ec3e000> whose view is not in the window hierarchy!
asked Mar 9 ummesalma 29.2k points
0 votes
1 answer 11 views
11 views
Problem: Unable to get MacPort functionality after installing Xcode 4.3. How do i trouble shoot my Xcode and MacPort interface?
asked Mar 15 ummesalma 29.2k points
1 vote
1 answer 407 views
407 views
Problem : I am beginner to Angular Js. I am trying to learn the AngularJS. Below is my code from my controllers.js file. 'use strict'; angular.module ( 'F1FeederApp.controllers' , [ ] ) .controller ( 'driversController' , function ( $myscope , myergastAPIservice ) ... url not allowed by $sceDelegate policy&rdquo; I am unable to figure out the cause of this error. Can someone guide me in fixing it?
asked Mar 27, 2020 morrisBson 3.2k points