Text  |   XML   |   Visible Warnings:

Pvm : Pvm analysis 1 : Null Pointer Dereference  at pvmd.c:1927

Categories: LANG.MEM.NPD CWE:476
Warning ID: 2503.2533
Procedure: work
Trace: View
Modified: Wed Sep 2 12:39:55 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/pvmd.c
   Enter work
 1696 work() 
 1697 {
 1698         static int lastpinged = 0;      /* host that got last keepalive msg */ 
 1699 #ifdef FDSETNOTSTRUCT 
 1700         fd_set rfds, wfds;                      /* result of select */ 
 1701         /* fd_set efds; */ 
 1702 #else 
 1703         struct fd_set rfds, wfds;       /* result of select */ 
 1704         /* struct fd_set efds; */ 
 1705 #endif 
 1706         int nrdy;                                       /* number of fds ready after select */ 
   ...
 1718         double tbpl;                            /* time at beginning of probe loop */ 
 1719         double toutpl;                          /* timeout in the probe loop */ 
 1720         int timed_out;
 1721         extern double dclock();
 1722 #endif 
 1723 #endif 
 1724 #ifdef  SHMEM 
 1725         int someclosed; 
 1726 #endif 
 1727  
 1728         gettimeofday(&tnow, (struct timezone*)0);
 1729         if (pvmdebmask || myhostpart) {
 1730                 PVM_TIMET time_temp;
 1731                 pvmlogprintf("%s (%s) %s %s\n",
 1732                                 hosts->ht_hosts[hosts->ht_local]->hd_name,
 1733                                 inadport_decimal(&hosts->ht_hosts[hosts->ht_local]->hd_sad),
 1734                                 myarchname,
 1735                                 PVM_VER);
 1736                 pvmlogprintf("ready ");
 1737                 time_temp = (PVM_TIMET) tnow.tv_sec;
 1738                 pvmlogprintf(ctime(&time_temp));
 1739         }
 1740  
 1741         /*
 1742         * check for default plug-in modules (& start them)
 1743         * (only if pvmd, not for pvmd'...)
 1744         */ 
 1745  
 1746         if ( myhostpart ) {
 1747                 char *av[5];
 1748                 char *buf;
 1749                 char *cmd;
 1750                 int ac;
 1751                 int i;
 1752  
 1753                 for ( i=0 ; modulenames[i] ; i++ ) {
 1754                         cmd = getenvmodulenames[i] );
 1755                         if ( cmd != NULL )
 1756                         {
   ...
 1765                                 }
 1766                                 if (buf) PVM_FREE( buf );
 1767                         }
 1768                 }
 1769         }
 1770  
 1771         /*
 1772         * remind myself to start those pesky slave pvmds 
 1773         */ 
 1774  
 1775         if (addmesg) {
 1776                 struct pmsg *mp = addmesg;
 1777  
 1778                 addmesg = 0;
 1779                 sendmessage(mp);
 1780         }
 1781  
 1782         /*
 1783         * init bail (for PVMDSTARTUP) and ping times 
 1784         */ 
 1785  
 1786         pvmgetclock(&tnow);
 1787         tout.tv_sec = DDBAILTIME;
 1788         tout.tv_usec = 0;
 1789         TVXADDY(&tbail, &tnow, &tout);
 1790  
 1791         tout.tv_sec = DDPINGTIME;
 1792         tout.tv_usec = 0;
 1793         TVXADDY(&tping, &tnow, &tout);
 1794  
 1795         /* init select fd sets */ 
 1796  
 1797         wrk_fds_init();
 1798  
 1799         if (loclsock >= 0)
 1800                 wrk_fds_add(loclsock, 1);
 1801         wrk_fds_add(netsock, 1);
 1802  
 1803         for (; ; ) {
 1804  
 1805                 /*
 1806                 *       clean up after any tasks that we got SIGCHLDs for 
 1807                 */ 
 1808 #ifdef IMA_BEOSCYLD 
 1809                 reap(SIGCLD); 
 1810 #endif 
 1811                 while (rdead != wdead) {
 1812                         if (deads[rdead].dd_pid == pprime) {
 1813                                 int cc;
 1814 #ifdef SOCKLENISUINT 
 1815 #if defined(IMA_AIX4SP2) || defined(IMA_AIX5SP2) \
 1816                 || defined(IMA_AIX56K64) || defined(IMA_LINUXALPHA)
 1817                                 unsigned int oslen;
 1818 #else 
 1819                                 size_t oslen;
 1820 #endif 
 1821 #else 
 1822                                 int oslen;
 1823 #endif 
 1824                                 struct sockaddr_in osad;
 1825                                 struct timeval t;
 1826                                 char buf[DDFRAGHDR];
 1827  
 1828                                 hostfailentry(hosts->ht_hosts[0]);
 1829                                 clear_opq_of((int)(TIDPVMD | hosts->ht_hosts[0]->hd_hostpart));
 1830                                 pprime = 0;
 1831  
 1832                                 while (1) {
 1833                                         FD_ZERO(&rfds);
 1834                                         FD_SET(ppnetsock, &rfds);
 1835                                         t.tv_sec = 0;
 1836                                         t.tv_usec = 0;
 1837                                         cc = select(ppnetsock + 1,
 1838 #ifdef  FDSETISINT 
 1839                                                         (int *)&rfds, (int *)0, (int *)0, 
 1840 #else 
 1841                                                         (fd_set *)&rfds, (fd_set *)0, (fd_set *)0,
 1842 #endif 
 1843                                                         &t);
 1844                                         if (cc == 1) {
 1845                                                 oslen = sizeof(osad);
 1846                                                 recvfrom(ppnetsock, buf, sizeof(buf),
 1847                                                                 0, (struct sockaddr*)&osad, &oslen);
 1848  
 1849                                         } else if (cc != -1 || errno != EINTR)
 1850                                                 break;
 1851                                 }
 1852  
 1853                         } else {
 1854                                 if (tp = task_findpid(deads[rdead].dd_pid)) {
 1855  
 1856                 /* check for output one last time 
 1857                    XXX this could be cleaner by going through main select again 
 1858                    XXX before flushing the task */ 
 1859  
 1860                                         tp->t_status = deads[rdead].dd_es;
 1861                                         tp->t_utime = deads[rdead].dd_ut;
 1862                                         tp->t_stime = deads[rdead].dd_st;
 1863                                         while (tp->t_out >= 0) {
 1864  
 1865 #ifdef FDSETNOTSTRUCT 
 1866                                                 fd_set rfds;
 1867 #else 
 1868                                                 struct fd_set rfds; 
 1869 #endif 
 1870  
 1871                                                 FD_ZERO(&rfds);
 1872                                                 FD_SET(tp->t_out, &rfds);
 1873                                                 TVCLEAR(&tout);
 1874                                                 if (select(tp->t_out + 1,
 1875 #ifdef  FDSETISINT 
 1876                                                                 (int *)&rfds, (int *)0, (int *)0, 
 1877 #else 
 1878                                                                 (fd_set *)&rfds, (fd_set *)0, (fd_set *)0,
 1879 #endif 
 1880                                                                 &tout) == 1)
 1881                                                         loclstout(tp);
 1882  
 1883                                                 else 
 1884                                                         break;
 1885                                         }
 1886 #if defined(IMA_PGON) || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2) \
 1887         || defined(IMA_AIX5SP2) || defined(IMA_BEOLIN) 
 1888                                         mpp_free(tp); 
 1889 #endif 
 1890                                         task_cleanup(tp);
 1891                                         task_free(tp);
 1892                                 }
 1893                         }
 1894                         if (++rdead >= ndead)
 1895                                 rdead = 0;
 1896                 }
 1897  
 1898                 netoutput();
 1899  
 1900                 if (runstate == PVMDHALTING) {
 1901                         pvmlogerror("work() pvmd halting\n");
 1902                         pvmbailout(0);
 1903                 }
 1904  
 1905                 /* bail if new slave and haven't been configured for too long */ 
 1906                 pvmgetclock(&tnow);
 1907                 if (runstate == PVMDSTARTUP && TVXLTY(&tbail, &tnow)) {
 1908                         pvmlogerror("work() run = STARTUP, timed out waiting for master\n");
 1909                         pvmbailout(0);
 1910                 }
 1911  
 1912                 /*
 1913                 * send keepalive message to remote pvmd once in a while 
 1914                 */ 
 1915                 if (TVXLTY(&tping, &tnow)) {
 1916                         if (pvmdebmask & (PDMPACKET|PDMSELECT))
 1917                                 pvmlogerror("work() ping timer\n");
 1918                         if (runstate == PVMDNORMAL || runstate == PVMDHTUPD) {
 1919                                 do {
 1920                                         if (++lastpinged > hosts->ht_last)
 1921                                                 lastpinged = 1;
 1922                                 } while (!(hp = hosts->ht_hosts[lastpinged]));
 1923  
 1924                                 if (hp->hd_hostpart != myhostpart 
 1925                                 && hp->hd_txq->pk_link == hp->hd_txq) {
true1926                                         mp = mesg_new(0);
mp <= 40951927                                         mp->m_tag = DM_NULL;     /* Null Pointer Dereference */
Preconditions
&$unknown_250467 != locltasks
hosts->ht_hosts[1]->hd_hostpart != 0
hosts->ht_hosts[1]->hd_txq = hosts->ht_hosts[1]->hd_txq->pk_link
opq->pk_tlink != opq
((char*)&$unknown_250467)[136] = 0
((char*)&$unknown_250467)[156] <= 0
((char*)&$unknown_250467)[216] >= 0
((char*)&$unknown_250467)[72] >= 0
((char*)&$unknown_250467)[88] >= 0
((char*)&$unknown_250467)[96] >= 0
((char*)&$unknown_250467)[104] <= -1
((char*)&$unknown_250467)[112] >= 0
loclsock <= -1
myhostpart = 0
pvmdebmask != 0
rdead != 0
runstate = 1
tnow.tv_usec <= 999999
wdead = 0
Postconditions
((char*)&((char*)$unknown_250467)[80])[16]' = 0
((char*)&((char*)$unknown_250467)[80])[24]' = 0
locltasks->t_plink' != locltasks
((char*)$unknown_250467)[80]' is freed
addmesg' = 0
$unknown_250467' is freed
atnewline' = 1
freepmsgs.m_link' = &freepmsgs.m_link
freepmsgs.m_rlink' = &freepmsgs.m_link
hp' = hosts->ht_hosts[1]
lastpinged' = 1
mp' = addmesg
mp' = 0
numpmsgs' = 0
rdead' = 0
tbail.tv_usec' = tnow.tv_usec
time_temp' = &$unknown_250456
tmbuf.tm_sec' = &$unknown_250480
tp' = &$unknown_250467
tping.tv_usec' = tnow.tv_usec
wrk_rfds.__fds_bits[15]' = 0
wrk_wfds.__fds_bits[15]' = 0




Change Warning 2503.2533 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: