Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Tue Jun 27, 2017 10:42 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: svn r1775 and bug #2185
PostPosted: Wed Apr 18, 2012 5:31 am 
Offline

Joined: Fri Nov 26, 2010 12:16 pm
Posts: 2
regarding this issue, i wanted to add a further comment, but due to the resolved state, it was not possible.

http://bugs.cacti.net/view.php?id=2185&nbn=16

putting that here then.

Quote:

Code:
[--SNIP--]
   /* loop through devices until done */
   while ((device_counter < num_rows) && (canexit == FALSE)) {
      while ((active_threads < set.threads) && (device_counter < num_rows) && (canexit == FALSE)) {
         mutex_status = thread_mutex_trylock(LOCK_THREAD);
   
         switch (mutex_status) {
         case 0:
.....

            /* populate the thread structure */
            if (!(poller_details = (poller_thread_t *)malloc(sizeof(poller_thread_t)))) {
               die("ERROR: Fatal malloc error: spine.c poller_details!");
            }

......
      usleep(internal_thread_sleep);
   }
......

   free(poller_details);

   /* tell Spine that it is now parent */
   set.parent_fork = SPINE_PARENT;

[--SNIP--]


given the 2 loops, and the switch case condition, the malloc happens 0, 1 or n times. n is the number of threads being set.

putting the free() after looping will solely try to free the last pointer to the allocated memory, but leaving all other pointers behind, leading into memory corruption (as the SIGABRT indicates).

given the 0.8.8 released code, the counts will be as follows

Code:
threads malloc free
0       0      1
1       1      1
n       n      1 <- X


r7115 will fix the bug, but not the leak - this small patch will work as another package revision for repoforge though.

a proper clean fix would be calling free() directly in the switch condition after having done everything, going into the next loop cycle.

i need to investigate further on that - our productive system triggering the memory corruption currently uses 7 threads.


@gandalf
i've been putting various debug hints into the icinga wiki, maybe that helps over here as well.
https://wiki.icinga.org/display/Dev/Debug
https://wiki.icinga.org/display/Dev/gdb


Top
 Profile  
 
 Post subject: Re: svn r1775 and bug #2185
PostPosted: Wed Apr 18, 2012 6:30 am 
Offline
Developer
User avatar

Joined: Thu Dec 02, 2004 2:46 am
Posts: 22461
Location: Muenster, Germany
I was thinking that way already, so thanks for the confirmation. I only did not find time to really track this down as you did, so I deactivate the invalid free as a first workaround. In case you come up with a patch, I'd love to consider that
R.

_________________
Official Cacti Documentation
Official Debugging Help
Central Plugin Repository
Central Templates Repository


Top
 Profile  
 
 Post subject: Re: svn r1775 and bug #2185
PostPosted: Wed Apr 18, 2012 10:53 am 
Offline

Joined: Fri Nov 26, 2010 12:16 pm
Posts: 2
your revert works fine over here in production, therefore sent to repoforge as well. for the real patch, i'll need to dive deeper into spine (which may take a while due to an upcoming icinga release).


Top
 Profile  
 
 Post subject: Re: svn r1775 and bug #2185
PostPosted: Wed Apr 18, 2012 11:00 am 
Offline
Developer
User avatar

Joined: Thu Dec 02, 2004 2:46 am
Posts: 22461
Location: Muenster, Germany
Please add any comments to that very cacti bug report, then. I'm tracking it as you already might know
R.

_________________
Official Cacti Documentation
Official Debugging Help
Central Plugin Repository
Central Templates Repository


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group