Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Leak  at lpvm.c:1841

Categories: ALLOC.LEAK CWE:401 CWE:771 CWE:773
Warning ID: 22100.29019
Procedure: mxfer
Trace: view
Modified: Thu Nov 26 11:29:38 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
   /kat0/fletcher/SATE/2010/pvm3/src/lpvm.c
   Enter mxfer
 1789 mxfer(txup, tmout) 
 1790         struct pmsg *txup;                      /* outgoing message or null */ 
 1791         struct timeval *tmout;          /* time limit to get at least one message */ 
 1792 {
 1793         struct ttpcb *txpcbp = 0;       /* route for ogm */ 
 1794         struct frag *txfp = 0;          /* cur ogm frag or null */ 
 1795         struct timeval tin;
 1796         struct timeval tnow;
 1797         struct timeval *tvp;
 1798 #ifdef FDSETNOTSTRUCT 
 1799         fd_set rfds, wfds;
 1800 #else 
 1801         struct fd_set rfds, wfds; 
 1802 #endif 
 1803         int wantmore = 1;                       /* nothing rxd yet and not timed out */ 
 1804         int gotem = 0;                          /* count of received msgs downloaded */ 
 1805         int ff;
 1806         int n;
 1807 #ifdef SOCKLENISUINT 
 1808 #if defined(IMA_AIX4SP2) || defined(IMA_AIX5SP2)
 1809         unsigned int oslen;
 1810 #else 
 1811         size_t oslen;
 1812 #endif 
 1813 #else 
 1814         int oslen;
 1815 #endif 
 1816         char *txcp = 0;                         /* point to remainder of txfp */ 
 1817         int txtogo = 0;                         /* len of remainder of txfp */ 
 1818         struct sockaddr_in sad;
 1819         int s;
 1820         struct ttpcb *pcbp;
 1821         char *inPlaceHeader = (char  *) NULL;   /* for inplace data */ 
 1822         int inPlaceBodyLen = 0;                                 /* len of inplace body */       
 1823         int bypassRead = FALSE;                         /* bypass reading packets before send?*/ 
 1824         int waitForOgmToComplete = FALSE;
 1825         int probedForIncomingPkts = FALSE;      /* need to probe for incoming pkts */ 
 1826         struct msgid *sendmsg = (struct msgid *) NULL;
 1827         char errtxt[64];
 1828  
 1829         int nfr = 0, totfr = 0;                         /* number frags read my mxinput */ 
 1830         int probe = 0;                                          /* called at a probe (nrecv) */ 
 1831  
 1832         if (tmout)
 1833         {
 1834                 pvmgetclock(&tin);
 1835                 probe = ( tmout -> tv_sec == 0 && tmout -> tv_usec == 0);
 1836         }
 1837  
 1838         if (txup) {     /* transmitting a umsg */ 
 1839                 txfp = txup->m_frag->fr_link;
 1840                 if (!txfp->fr_buf) {
allocated inside call1841                         if (!(txfp = fr_new(MAXHDR)))     /* Leak */
     /kat0/fletcher/SATE/2010/pvm3/src/pvmfrag.c
     Enter mxfer / fr_new
 161   struct frag * 
 162   fr_new(len) 
 163           int len;        /* (max) buffer size or 0 */ 
 164   {
 165           struct frag *fp;
 166    
 167           if (!(fp = frag_get_header()))
 168                   goto oops;
 169    
 170           if (len) {      /* slave frag */ 
 171                   fp->fr_link = fp->fr_rlink = 0;   /* Useless Assignment (ID: 22.28603) */
allocated inside call172                   if (!(fp->fr_dat = fp->fr_buf = da_new(len))) {
       /kat0/fletcher/SATE/2010/pvm3/src/pvmdabuf.c
       Enter mxfer / fr_new / da_new
 83     char * 
 84     da_new(len) 
 85             int len;
 86     {
 87             char *p;
 88      
referenced by returned value89             if (p = TALLOC(len + RCOFFSET, char, "data")) {
referenced by p90                     p += RCOFFSET;
 91                     *(int*)(p - sizeof(int)) = 1;
 92             }
 93             return p;
referenced by returned value94     } 
       Exit mxfer / fr_new / da_new
 173                           frag_put_header(fp);
 174                           goto oops;
 175                   }
referenced by freefrags.fr_link->fr_dat and 1 others176                   fp->fr_max = len;
 177    
 178           } else {        /* master */ 
 179                   fp->fr_link = fp->fr_rlink = fp;
 180                   fp->fr_dat = fp->fr_buf = 0;
 181                   fp->fr_max = 0;
 182           }
 183           fp->fr_len = 0;
 184           fp->fr_u.ref = 1;
 185           fp->fr_u.dab = 1;
 186           fp->fr_u.spr = 0;
 187           fp->fr_rip = 0;
 188   #ifdef IMA_CSPP 
 189           fp->fr_num_unpacked = 0; 
 190   #endif 
 191   /*
 192           pvmlogprintf("fr_new() %d = %lx\n", len, fp);
 193   */ 
 194           return fp;
 195    
 196   oops: 
 197           pvmlogerror("fr_new() can't get memory\n");
 198           pvmbailout(0);
 199           return (struct frag*)0;   /* Unreachable Computation (ID: 23.28605) */
 200   } 
     Exit mxfer / fr_new
 1842                                 return PvmNoMem;
referenced by freefrags.fr_link->fr_dat and 1 others1843                         txfp->fr_dat += MAXHDR;
 1844                         LISTPUTBEFORE(txup->m_frag, txfp, fr_link, fr_rlink);
 1845                 }
 1846                 /* Get connection info for this dest. If none, go to pvmd */ 
 1847                 if (!(txpcbp = ttpcb_find(txup->m_dst)) || txpcbp->tt_state != TTOPEN)
 1848                         txpcbp = topvmd;
 1849                 txup->m_ref++;
 1850                 bypassRead = TRUE;              /* bypass reading the first time through */ 
 1851         }
 1852  
 1853         if (pvmdebmask & PDMMESSAGE) {
 1854                 pvmlogprintf("mxfer() mid %d", (txup ? txup->m_mid : 0));
 1855                 if (txup)
 1856                         pvmlogprintf(" ctx %d tag %s dst t%x route t%x",
 1857                                         txup->m_ctx,
 1858                                         pvmnametag(txup->m_tag, (int *)0),
 1859                                         txup->m_dst, txpcbp->tt_tid);
 1860                 if (tmout)
 1861                         pvmlogprintf(" tmout %d.%06d\n",
 1862                                         tmout->tv_sec, tmout->tv_usec);
 1863                 else 
   ...
 1872          *              1) Sending a frag 
 1873          * OR   2) Received *part* of an incoming frag from the daemon 
 1874          * OR   3) Wantmore is true 
 1875          * OR   4) Need the current OGM to complete its asynch send 
 1876          * OR   5) We haven't probed at least once for incoming packets 
 1877          *
 1878          * wantmore is initialized to  TRUE  -> loop exec'ed at least once 
 1879         */ 
 1880  
 1881  
 1882         while (txfp || topvmd->tt_rxf || wantmore || waitForOgmToComplete 
 1883                         || !probedForIncomingPkts 
 1884         )  
 1885         {
 1886  
 1887                 totfr = 0;  
 1888  
 1889                 /* Either we are sending something, or have a partial recv'd frag */ 
 1890                 if (txfp || topvmd->tt_rxf)                     /* gotta block */ 
 1891                 {
 1892                         /* must block if sending any message, or receiving from pvmd */ 
 1893                         tvp = (struct timeval *) NULL;
 1894  
 1895                 }  
 1896                 else 
 1897                 {
 1898                         if (wantmore)  
 1899                         {
 1900                                 /* Calculate how long to wait inside the "select"
 1901                                  *      tval = NULL means wait forever 
 1902                                  *  tval = (0,0) means probe 
 1903                                  *      tval = (x,y) means wait at most x sec + y usec 
   ...
 1930                                 tvp = &tnow;
 1931                         }
 1932                 }
 1933  
 1934                 /* Here we are setting the read and write file descriptors for 
 1935                  *      the following select statement.  
 1936                 */ 
 1937  
 1938  
 1939 #if !defined(IMA_MPP)
 1940                 rfds = pvmrfds;
 1941                 FD_ZERO(&wfds);
 1942                 if (txfp)
 1943                         FD_SET(txpcbp->tt_fd, &wfds);
 1944 #endif 
 1945  
 1946                 if (pvmdebmask & PDMSELECT) {
 1947                         if (tvp)
 1948                                 pvmlogprintf("mxfer() select timeout %d.%06d\n",
 1949                                                 tvp->tv_sec, tvp->tv_usec);
 1950                         else 
 1951                                 pvmlogprintf("mxfer() select timeout inf\n");
 1952 #if !defined(IMA_MPP)
 1953                         print_fdset("mxfer() rfds=", pvmnfds, &rfds);
 1954                         print_fdset("mxfer() wfds=", pvmnfds, &wfds);
 1955 #endif 
 1956                 }
 1957  
 1958 #if !defined(IMA_MPP)
 1959                 probedForIncomingPkts = TRUE;
 1960                 if ((n = select(pvmnfds,
 1961 #ifdef  FDSETISINT 
 1962                                 (int *)&rfds, (int *)&wfds, (int *)0, 
 1963 #else 
 1964                                 (fd_set *)&rfds, (fd_set *)&wfds, (fd_set*)0,
 1965 #endif 
 1966                                 tvp)) == -1   /* Uninitialized Variable (ID: 343.29021) */
 1967                 && errno != EINTR 
 1968 #ifdef IMA_LINUX 
 1969                 && errno != EAGAIN 
 1970 #endif 
 1971                 ) {
 1972                         pvmlogperror("mxfer() select");
 1973                         return PvmSysErr;
 1974                 }
 1975                 if (pvmdebmask & PDMSELECT) {
 1976                         pvmlogprintf("mxfer() select returns %d\n", n);
 1977                 }
 1978                 if (n == -1)
 1979                         continue;
 1980         /*
 1981         * if pvmd conn has data ready, read packets 
 1982         */ 
 1983  
 1984                 if (FD_ISSET(topvmd->tt_fd, &rfds) 
 1985                         && !(mxfersingle && gotem))  
 1986                 {
 1987                         if ((n = mxinput(topvmd, &nfr)) < 0) {
     Enter mxfer / mxinput
referenced by freefrags.fr_link->fr_dat and 1 others1545   mxinput(pcbp, nfr) 
 1546           struct ttpcb *pcbp;
 1547           int *nfr;                               /* number of frags read */ 
 1548   {
 1549           int gotem = 0;                  /* num msgs added to pvmrxlist */ 
 1550           struct frag *fp;                /* shadows pcbp->tt_rxf */ 
 1551           struct frag *fp2;
 1552           int n;                                  /* bytes received */ 
 1553           int m;                                  /* length of fragment */ 
 1554           struct pmsg *rxup;              /* message containing this frag */ 
 1555           struct pmsg *hdfrgpile;
 1556           char *cp;                               /* gp */ 
 1557           int src;
 1558           int dst;
 1559           int ff;
 1560           static int fairprobe = 0;
 1561    
 1562           *nfr = 0;
 1563    
 1564    
 1565   #if defined(IMA_MPP) 
 1566    
 1567           /* Messages from Tasks and  Messages from the daemon  are probed 
 1568            * fairprobe makes sure that neither interface gets starved.  
 1569            * fairprobe is toggled when an EOM is found   
 1570           */ 
 1571    
 1572           switch (fairprobe)
     ...
 1584                           if ((fp = pvm_readfrompvmd()) == (struct frag *) NULL)  
 1585                                   fp = pvm_readfrompeer();
 1586                           break;
 1587    
 1588           }
 1589    
 1590           if (!fp)  
 1591                   return gotem;   /* didn't read anything */ 
 1592    
 1593   #else 
 1594           if (!pcbp->tt_rxf)
 1595                   if (!(pcbp->tt_rxf = fr_new(pvmfrgsiz)))   /* Redundant Condition (ID: 335.29014) */
       /kat0/fletcher/SATE/2010/pvm3/src/pvmfrag.c
       Enter mxfer / mxinput / fr_new
referenced by freefrags.fr_link->fr_dat and 1 others161     struct frag * 
 162     fr_new(len) 
 163             int len;        /* (max) buffer size or 0 */ 
 164     {
 165             struct frag *fp;
 166      
 167             if (!(fp = frag_get_header()))
 168                     goto oops;
 169      
 170             if (len) {      /* slave frag */ 
 171                     fp->fr_link = fp->fr_rlink = 0;   /* Useless Assignment (ID: 22.28603) */
 172                     if (!(fp->fr_dat = fp->fr_buf = da_new(len))) {
       Exit mxfer / mxinput / fr_new
     Exit mxfer / mxinput
Preconditions
&$unknown_1178785 != 0
tmout->tv_usec != 0
txup->m_frag->fr_link->fr_buf = 0
ttlist->tt_link->tt_tid <= txup->m_dst - 1
((char*)$unknown_1178783)[12] != 3
topvmd->tt_rxf = 0
tmout->tv_sec = 0
$unknown_1178783 != ttlist
((char*)&$unknown_1178783)[8] <= txup->m_dst - 1
mxfersingle = 0
numfrags != 0
numfrags != 1
pvmfrgsiz != 0
pvmnfds >= 0
ttlist != ttlist->tt_link
Postconditions
freefrags.fr_link->fr_link->fr_rlink' = freefrags.fr_link->fr_rlink
freefrags.fr_link->fr_max' = 48
freefrags.fr_link->fr_len' = 0
freefrags.fr_link->fr_u.ref' = 1
freefrags.fr_link->fr_u.dab' = 1
freefrags.fr_link->fr_u.spr' = 0
freefrags.fr_link->fr_rlink' = 0
freefrags.fr_link->fr_rip' = 0
freefrags.fr_link->fr_buf' = 0
freefrags.fr_link->fr_dat' = 0
freefrags.fr_link->fr_rlink->fr_link' = freefrags.fr_link->fr_link
freefrags.fr_link->fr_link' = 0
*stderr' is allocated by fopen
bytes_before(stderr)' = 0
__result' = &$unknown_1178785
bypassRead' = 1
errno' != 0
fp' = freefrags.fr_link
gotem' = 0
gotem' = 0
bytes_after(&$heap_336487)' = 64
$heap_336487' is allocated by malloc
$heap_336487' is allocated
bytes_before(&$heap_336487)' = 0
((char*)&$heap_336487)[12]' = 1
inPlaceBodyLen' = 0
inPlaceHeader' = 0
len' = pvmfrgsiz
n' >= 0
n' <= pvmnfds
newline' = 0
nfr' = 0
nfr' = &nfr
numfrags' = numfrags - 2
pcbp' = topvmd
probe' = 0
probedForIncomingPkts' = 1
sendmsg' = 0
tin.tv_sec' = &$unknown_1178782
totfr' = 0
tvp' = 0
txcp' = 0
txfp' = freefrags.fr_link
txpcbp' = topvmd
txtogo' = 0
waitForOgmToComplete' = 0
wantmore' = 1




Change Warning 22100.29019 : Leak

Priority:
State:
Finding:
Owner:
Note: