Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > C code Help needed

C code Help needed
Thread Tools
Junior Member
Join Date: Aug 2000
Location: Montreal, QC, Canada
Status: Offline
Reply With Quote
Mar 31, 2003, 02:08 PM
 
I am trying to complete a project for a University class where we have to create a SNMP agent. It was suggested that we download and use a program that generates the C code for the agent, all we have to do is generate the code and then compile it after we add a few patches.

The first few times that I compiled the code, I had to manually run 'ranlib' on the libraries that were created in order to get my software to compile. I simply ran 'ranlib' without any options. Then I completed the compile.

The agent that was created seemed to be working correctly, part started crashing with malloc errors. i.e.
*** malloc[893]: Deallocation of a pointer not malloced: 0x672d456e; This could be a double free(), or free() called with the middle of an allocated block; Try setting environment variable MallocHelp to see tools to help debug
Segmentation fault

When I completely redid the generation of the code, everything was working. I left it alone for a couple of days and went back to finish a couple of minor things, but the code is crashing once again.

Most of the code that I'm working with is generated by the utility that I downloaded. Does anybody have any suggestions?
     
Dedicated MacNNer
Join Date: Apr 2001
Location: Bethesda, MD
Status: Offline
Reply With Quote
Apr 1, 2003, 09:38 AM
 
You've either trashed a pointer that is then getting freed or you've trashed the heap by overwriting memory that you shouldn't have. Can you run your program in a debugger to see where it's crashing? That pointer value looks kind of funny, like it isn't pointing into the heap. May it got overwritten.

When I get funny pointer crashes that I can't figure out, I use dmalloc to track it down. It's a debugging version of malloc that checks the consistancy of the heap every so often. It makes your program run alot slower because of all the testing, but it's invaluable for memory errors. You can get it at dmalloc.org.
     
   
Thread Tools
Forum Links
Forum 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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 03:18 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2