Text  |   XML   |   Visible Warnings:

Pvm : Pvm analysis 1 : Leak  at ddpro.c:2193

Categories: LANG.ALLOC.LEAK CWE:401 CWE:771 CWE:773
Warning ID: 2557.2588
Procedure: startack
Trace: View
Modified: Wed Sep 2 12:41:13 2009   show details
 
Priority: None
State: None
Finding: None
Owner: None
  edit properties

Legend [ X ]
Warning Location
Contributes
Parse Error
Other Warning
Two or More Loop Iterations
On Execution Path
Comment
Macro
Preprocessor
Include
Keyword
Preprocessed Away

Source  |  Language: C Hide Legend     
ProblemLineSource
   /u1/paul/SATE/2010/c/pvm/pvm3/src/ddpro.c
   Enter startack
 2056 startack(wp, mp) 
 2057         struct waitc *wp;               /* wait context on hoster */ 
 2058         struct pmsg *mp;
 2059 {
 2060         struct hostd *hp;
 2061         struct pmsg *mp2;
 2062         struct waitc *wp2;              /* seed waitc for htupd peer group */ 
 2063         struct waitc *wp3;
 2064         int count;                              /* num of new hosts */ 
 2065         int happy;                              /* num of happy new hosts */ 
 2066         struct waitc_add *wxp;
   ...
 2070         int i, j;
 2071         int t;
 2072         int hh;
 2073         char *buf;
 2074         char buf2[256];
 2075  
 2076         /*
 2077         * unpack startup results, update hosts in wait context 
 2078         */ 
 2079  
 2080         wxp = (struct waitc_add *)wp->wa_spec;
 2081         count = wxp->w_num;
 2082         upkint(mp, &j);
 2083  
 2084         while (j-- > 0) {
 2085                 if (upkuint(mp, &t) || upkstralloc(mp, &buf)) {
 2086                         pvmlogerror("startack() bad message format\n");
 2087                         pkint(wp->wa_mesg, PvmDSysErr);
 2088                         sendmessage(wp->wa_mesg);
 2089                         wp->wa_mesg = 0;
 2090                         wait_delete(wp);
 2091                         busyadding = 0;
 2092                         return 0;
 2093                 }
 2094                 for (i = count; i-- > 0 && wxp->w_hosts[i]->hd_hostpart != t; ) ;
   ...
 2127                 hp->hd_mtu = atoi(av[3]);
 2128                 hp->hd_dsig = atoi(av[4]);
 2129  
 2130                 PVM_FREE(buf);
 2131         }
 2132  
 2133         /*
 2134         * update reply message to add-host requestor 
 2135         */ 
 2136  
 2137         mp2 = wp->wa_mesg;
 2138         pkint(mp2, count);
 2139         pkint(mp2, 0);  /* XXX narches = 0 for now */ 
 2140         for (i = 0; i < count; i++) {
 2141                 hp = wxp->w_hosts[i];
 2142                 if (hp->hd_err) {
 2143                         pkint(mp2, hp->hd_err);
 2144                         pkstr(mp2, "");
 2145                         pkstr(mp2, "");
 2146                         pkint(mp2, 0);
 2147                         pkint(mp2, 0);
 2148  
 2149                 } else {
 2150                         pkint(mp2, hp->hd_hostpart);
 2151                         pkstr(mp2, hp->hd_name);
 2152                         pkstr(mp2, hp->hd_arch);
 2153                         pkint(mp2, hp->hd_speed);
 2154                         pkint(mp2, hp->hd_dsig);
 2155                 }
 2156         }
 2157  
 2158         /*
 2159         * delete broken ones, done now if none succeeded,
 2160         * otherwise done when host table update is complete.
 2161         */ 
 2162  
 2163         for (j = i = 0; i < count; i++)
 2164                 if (!wxp->w_hosts[i]->hd_err) {
 2165                         hp = wxp->w_hosts[i];
 2166                         wxp->w_hosts[i] = 0;
 2167                         wxp->w_hosts[j++] = hp;
 2168  
 2169                 } else {
 2170                         hd_unref(wxp->w_hosts[i]);
 2171                         wxp->w_hosts[i] = 0;
 2172                 }
 2173         count = j;
 2174  
 2175         if (count < 1) {
 2176                 busyadding = 0;
 2177                 sendmessage(wp->wa_mesg);
 2178                 wp->wa_mesg = 0;
 2179                 free_waitc_add(wxp);
 2180                 wait_delete(wp);
 2181                 return 0;
 2182         }
 2183  
 2184         wp2 = wait_new(WT_HTUPD);
 2185         wp2->wa_dep = wp->wa_dep;
 2186         wp2->wa_mesg = wp->wa_mesg;
 2187         wp->wa_mesg = 0;
 2188  
 2189         /*
 2190         * make next host table 
 2191         */ 
 2192  
allocated inside call2193         newhosts = ht_new(1);     /* Leak */
     /u1/paul/SATE/2010/c/pvm/pvm3/src/host.c
     Enter startack / ht_new
 483   struct htab * 
 484   ht_new(siz) 
 485           int siz;                /* initial length of ht_hosts[] */ 
 486   {
 487           struct htab *htp;
 488    
 489           if (siz < 1)
 490                   siz = 1;
 491           htp = TALLOC(1, struct htab, "ht1");
 492           BZERO((char*)htp, sizeof(struct htab));   /* Null Pointer Dereference (ID: 2469.2497) */
 493           htp->ht_last = siz;
referenced by returned value494           htp->ht_hosts = TALLOC(siz + 1, struct hostd*, "ht2");
referenced by htp->ht_hosts495           BZERO((char*)htp->ht_hosts, (siz + 1) * sizeof(struct hostd*));   /* Null Pointer Dereference (ID: 2468.2496) */
 496           return htp;
referenced by ht_new$return->ht_hosts497   } 
     Exit startack / ht_new
referenced by newhosts->ht_hosts2194         newhosts->ht_serial = hosts->ht_serial + 1;
 2195         newhosts->ht_master = hosts->ht_master;
 2196         newhosts->ht_cons = hosts->ht_cons;
 2197         newhosts->ht_local = hosts->ht_local;
 2198  
 2199         for (i = 0; i < count; i++)
 2200                 ht_insert(newhosts, wxp->w_hosts[i]);
     /u1/paul/SATE/2010/c/pvm/pvm3/src/host.c
     Enter startack / ht_insert
referenced by newhosts->ht_hosts507   ht_insert(htp, hp) 
 508           struct htab *htp;
 509           struct hostd *hp;
 510   {
 511           int hh;
 512           int i;
 513           unsigned long mask = 0, tmpmask;
 514    
 515           int *dsigs;
 516           int ndsigs;
 517           int found;
 518           int d;
 519    
 520           hh = (hp->hd_hostpart & tidhmask) >> (ffs(tidhmask) - 1);
 521    
 522           /* extend ht_hosts[] if no room */ 
 523    
 524           if (hh > htp->ht_last) {
 525                   int n = htp->ht_last;
 526    
 527                   htp->ht_last = (hh * 3) / 2;
 528                   htp->ht_hosts = TREALLOC(htp->ht_hosts, htp->ht_last + 1, struct hostd*);
referenced by $param_1529                   while (++n <= htp->ht_last)
 530                           htp->ht_hosts[n] = 0;   /* Null Pointer Dereference (ID: 2570.2602) */  /* 6 more... */
 531           }
 532    
 533           /* if already have an entry, take this as an update XXX kind of a hack */ 
 534    
 535           if (htp->ht_hosts[hh]) {        /* already have an entry */ 
 536    
 537                   struct hostd *hp2 = htp->ht_hosts[hh];
 538    
 539                   if (hp->hd_name) {
 540                           if (hp2->hd_name)
 541                                   PVM_FREE(hp2->hd_name);
 542                           hp2->hd_name = STRALLOC(hp->hd_name);   /* Null Pointer Dereference (ID: 2474.2502) */
 543                   }
 544                   if (hp->hd_arch) {
 545                           if (hp2->hd_arch)
 546                                   PVM_FREE(hp2->hd_arch);
 547                           hp2->hd_arch = STRALLOC(hp->hd_arch);   /* Null Pointer Dereference (ID: 2473.2501) */
 548                   }
 549                   hp2->hd_dsig = hp->hd_dsig;
 550                   hp2->hd_mtu = hp->hd_mtu;
 551                   hp2->hd_sad = hp->hd_sad;
 552                   hp2->hd_speed = hp->hd_speed;
 553    
 554           } else {                                        /* add new entry */ 
 555    
 556                   htp->ht_hosts[hh] = hp;
 557                   if (hh)
 558                           htp->ht_cnt++;
 559                   hp->hd_ref++;
 560           }
 561    
 562           /* update number of arches */ 
 563    
leaked564           dsigs = TALLOC( htp->ht_cnt, int, "dsigs");
     Exit startack / ht_insert
Preconditions
&$unknown_559752 >= 512
((char*)((char*)((char*)*$param_1)[72])[8])[80] = 0
waitlist->wa_wid >= widbase + 2
((char*)*$param_1)[72] = 1
widrange <= lastwid
Postconditions
waitlist->wa_rlink' = &$heap_32840
waitlist->wa_rlink->wa_link' = &$heap_32840
count' = 1
$heap_32840' = waitlist
bytes_after(&$heap_32840)' = 80
$heap_32840' is allocated by malloc
$heap_32840' is allocated
bytes_before(&$heap_32840)' = 0
((char*)&$heap_32840)[16]' = widbase + 1
((char*)&$heap_32840)[20]' = 6
((char*)&$heap_32840)[24]' = 0
((char*)&$heap_32840)[28]' = 0
((char*)&$heap_32840)[32]' = ((char*)$param_1)[32]
((char*)&$heap_32840)[56]' = ((char*)$param_1)[56]
((char*)&$heap_32840)[64]' = 0
((char*)&$heap_32840)[72]' = 0
((char*)&$heap_32840)[8]' = waitlist->wa_rlink
$heap_32841' = hosts->ht_serial + 1
bytes_after(&$heap_32841)' = 40
$heap_32841' is allocated by malloc
$heap_32841' is allocated
bytes_before(&$heap_32841)' = 0
strlen(&$heap_32841)' = 0
((char*)&$heap_32841)[16]' = hosts->ht_cons
((char*)&$heap_32841)[20]' = hosts->ht_local
((char*)&$heap_32841)[32]' = 0
((char*)&$heap_32841)[4]' >= -1
((char*)&$heap_32841)[4]' <= 1
((char*)&$heap_32841)[8]' = ((char*)&$heap_32841)[8] + 1
((char*)&$heap_32841)[12]' = hosts->ht_master
$heap_32842' = 0
bytes_after(&$heap_32842)' = 16
$heap_32842' is allocated by malloc
$heap_32842' is allocated
bytes_before(&$heap_32842)' = 0
strlen(&$heap_32842)' = 0
hh' = &$unknown_559752
hp' = ((char*)((char*)*$param_1)[72])[8]
hp' = ((char*)((char*)*$param_1)[72])[8]
htp' = &$heap_32841
i' = 0
j' = 1
lastwid' = 1
mask' = 0
mp' = $param_2
mp2' = ((char*)$param_1)[56]
n' = 2
newhosts' = &$heap_32841
wp' = $param_1
wp2' = &$heap_32840
wxp' = ((char*)$param_1)[72]




Change Warning 2557.2588 : Leak

Priority:
State:
Finding:
Owner:
Note: