Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
i have created a thread in which i am allocating memory to a pointer,freeing it inside the same. The function is being called in more than one thread.but some times it is getting crashed because of EXC_BAD_INSTRUCTION and at log it is giving incorrect checksum for frees object - object was probably modified after being freed.


this is the code
Posted
Updated 18-May-12 10:09am
v3
Comments
Richard MacCutchan 18-May-12 6:28am    
Very interesting, but I do not think that anyone can help you without a lot more information.
subrata kumar Nayak 18-May-12 7:14am    
sry....i don't know what i need to give as more information.......
subrata kumar Nayak 18-May-12 8:22am    
above i have updated the question with code ........
Richard MacCutchan 18-May-12 12:44pm    
Post the code here, not on some other site. Note, use the "Improve Question" link and put <pre> tags around it. Tell us exactly which line gets an error and what the error is.
CPallini 18-May-12 8:39am    
Is the pointer variable shared among the threads?

1 solution

you need to balance the memory allocations per thread. So beware of accessing memory in different threads, ie per global objects.

Take care in exiting every thread that cleanup is fine.

Dont use functions or API-Calls in destructors!!!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900