Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Null Pointer Dereference  at task.c:837

Categories: LANG.MEM.NPD CWE:476
Warning ID: 82.28672
Procedure: task_cleanup
Trace: view
Modified: Thu Nov 26 11:27:20 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/task.c
   Enter task_cleanup
 660 task_cleanup(tp) 
 661         struct task *tp;
 662 {
 663         struct pmsg *mp;
 664         struct waitc *wp, *wp2;
 665         struct task *tp2;
 666         struct pvmmentry *ep;
 667         struct hostd *hp;
 668         struct pmsg *mpd;
 669         char buf[512];
 670         int hh;
 671  
 672         /* notify anyone who asked */ 
 673  
 674         if (tp->t_tid) {
 675                 if (pvmdebmask & PDMTASK)
 676                         pvmlogprintf("task_cleanup() t%x\n", tp->t_tid);
 677  
 678                 for (wp = waitlist->wa_link; wp != waitlist; wp = wp->wa_link) {
 679  
 680         /* waits depending on this task */ 
 681  
 682                         if (wp->wa_on == tp->t_tid) {
 683                                 switch (wp->wa_kind) {
 684  
 685                                 case WT_HOSTSTART: 
 686                                         busyadding = 0;
 687                                         free_waitc_add((struct waitc_add *)wp->wa_spec);
 688                                         pkint(wp->wa_mesg, PvmDSysErr);
 689                                         sendmessage(wp->wa_mesg);
 690                                         wp->wa_mesg = 0;
 691                                         if (pvmdebmask & (PDMTASK|PDMSTARTUP))
 692                                                 pvmlogprintf( 
 693                                                         "task_cleanup() hoster t%x takes wid %d with it\n",
 694                                                         tp->t_tid, wp->wa_wid);
 695                                         break;
 696  
 697                                 case WT_TASKSTART: 
 698                                         if (wp->wa_tid) {
 699                                                 if (pvmdebmask & PDMTASK) {
 700                                                         pvmlogprintf( 
 701                                                                 "task_cleanup() tasker t%x takes t%x with it\n",
 702                                                                 tp->t_tid, wp->wa_tid);
 703                                                 }
 704                                                 if (tp2 = task_find(wp->wa_tid)) {
 705                                                         wp->wa_tid = 0;
 706                                                         task_cleanup(tp2);
 707                                                         task_free(tp2);
 708                                                 }
 709                                         }
 710                                         break;
 711  
 712                                 case WT_TASKX: 
 713                                         if (wp->wa_tid && wp->wa_mesg) {
 714                                                 sendmessage(wp->wa_mesg);
 715                                                 wp->wa_mesg = 0;
 716                                         }
 717                                         mb_tidy(tp->t_tid);
 718                                         break;
 719  
 720                                 case WT_RESET: 
 721                                         if (wp->wa_tid && wp->wa_mesg) {
 722                                                 sendmessage(wp->wa_mesg);
 723                                                 wp->wa_mesg = 0;
 724                                         }
 725                                         mb_tidy_reset(tp->t_tid);
 726                                         break;
 727  
 728                                 case WT_RECVINFO: 
 729                                         /* clean up pending recvinfo */ 
 730                                         ep = (struct pvmmentry *) wp->wa_spec;
 731                                         if ( ep->me_msg )       /* class name (overload :-Q) */ 
 732                                                 PVM_FREE( ep->me_msg );
 733                                         PVM_FREE( ep );
 734                                         break;
 735  
 736                                 case WT_HOSTA: 
 737                                         break;
 738  
 739                                 default: 
 740                                         pvmlogprintf( 
 741                                                         "task_cleanup() can't deal with wait kind %d\n",
 742                                                         wp->wa_kind);
 743                                         break;
 744                                 }
 745                                 wp2 = wp;
 746                                 wp = wp->wa_rlink;
 747                                 wait_delete(wp2);
 748                                 continue;
 749                         }
 750  
 751         /* waits this task was waiting on */ 
 752  
 753                         if (wp->wa_tid == tp->t_tid) {
 754                                 switch (wp->wa_kind) {
 755  
 756                                 case WT_HOSTF: 
 757                                 case WT_HOSTA: 
 758                                 case WT_TASKX: 
 759                                 case WT_ROUTEA: 
 760                                 case WT_ROUTED: 
 761                                 case WT_TASKSTART: 
 762                                         wp2 = wp;                               /* some kinds we can toss now */ 
 763                                         wp = wp->wa_rlink;
 764                                         wait_delete(wp2);
 765                                         break;
 766  
 767                                 default: 
 768                                         wp->wa_tid = 0;                 /* in case tid gets recycled */ 
 769                                         break;
 770                                 }
 771                         }
 772                 }
 773  
 774                 /* notify the scheduler */ 
 775  
 776                 if ((tp->t_sched)&&(tp->t_schedlmsg!=SM_TASKX)) {
 777                         mp = mesg_new(0);
 778                         mp->m_dst = tp->t_sched;   /* Null Pointer Dereference (ID: 83.28673) */
 779                         mp->m_tag = SM_TASKX;
 780                         tp->t_schedlmsg = SM_TASKX;
 781                         if (pvmdebmask & PDMSCHED) {
 782                                 pvmlogprintf("task_cleanup() taskx to t%x status = 0x%x\n",
 783                                                 tp->t_sched, tp->t_status);
 784                         }
 785                         pkint(mp, tp->t_tid);
 786                         pkint(mp, tp->t_status);
 787                         pkint(mp, (int)tp->t_utime.tv_sec);
 788                         pkint(mp, (int)tp->t_utime.tv_usec);
 789                         pkint(mp, (int)tp->t_stime.tv_sec);
 790                         pkint(mp, (int)tp->t_stime.tv_usec);
 791                         sendmessage(mp);
 792                 }
 793  
 794                 /* check if it's the hoster */ 
 795  
 796                 if (tp->t_tid == hostertid) {
 797                         if (pvmdebmask & (PDMTASK|PDMSTARTUP)) {
 798                                 pvmlogprintf("task_cleanup() unreg hoster t%x\n", tp->t_tid);
 799                         }
 800                         hostertid = 0;
 801                 }
 802  
 803                 /* check if it's the tasker */ 
 804  
 805                 if (tp->t_tid == taskertid) {
 806                         if (pvmdebmask & PDMTASK) {
 807                                 pvmlogprintf("task_cleanup() unreg tasker t%x\n", tp->t_tid);
 808                         }
 809                         taskertid = 0;
 810                 }
 811  
 812                 /* check if it's the tracer */ 
 813  
 814                 if (tp->t_tid == pvmtracer.trctid) {
 815  
 816                         if (pvmdebmask & PDMTASK) {
 817                                 pvmlogprintf("task_cleanup() unreg tracer t%x\n",
 818                                                 tp->t_tid);
 819                         }
 820  
 821                         pvmtracer.trctid = 0;
 822                         pvmtracer.trcctx = 0;
 823                         pvmtracer.trctag = 0;
 824                         pvmtracer.outtid = 0;
 825                         pvmtracer.outctx = 0;
 826                         pvmtracer.outtag = 0;
 827                         TEV_MASK_INIT(pvmtracer.tmask);
 828                         pvmtracer.trcbuf = 0;
 829                         pvmtracer.trcopt = 0;
 830  
 831                         /* tell the other pvmds */ 
 832  
 833                         for (hh = hosts->ht_last; hh > 0; hh--) {
 834                                 if (hh != hosts->ht_local 
 835                                                 && (hp = hosts->ht_hosts[hh])) {
true836                                         mpd = mesg_new(0);
mpd <= 4095837                                         mpd->m_tag = DM_SLCONF;     /* Null Pointer Dereference */
 838                                         mpd->m_dst = hp->hd_hostpart | TIDPVMD;
 839                                         pkint(mpd, DM_SLCONF_TRACE);
 840                                         sprintf(buf, "%x %d %d %x %d %d %d %d %s",
 841                                                 pvmtracer.trctid, pvmtracer.trcctx,
 842                                                         pvmtracer.trctag,
 843                                                 pvmtracer.outtid, pvmtracer.outctx,
 844                                                         pvmtracer.outtag,
 845                                                 pvmtracer.trcbuf, pvmtracer.trcopt,
 846                                                 pvmtracer.tmask);
 847                                         pkstr(mpd, buf);
 848                                         sendmessage(mpd);
Preconditions
&$unknown_148003 != waitlist
tp->t_tid = pvmtracer.trctid
tp->t_sched != 0
tp->t_schedlmsg != -2147221493
hosts->ht_hosts[1] != 0
((char*)&((char*)$unknown_148003)[36])[20] <= 1
hosts->ht_local != 1
hosts->ht_last >= 2
waitlist->wa_link != waitlist
$unknown_148003 >= 0
((char*)&$unknown_148003)[16] != hostertid
((char*)&$unknown_148003)[28] >= 0
((char*)&$unknown_148003)[12] = 14
hostertid != 0
hostertid = taskertid
pvmtracer.trctid = taskertid
Postconditions
((char*)&((char*)((char*)$unknown_148003)[36])[12])[24]' = ((char*)&((char*)((char*)$unknown_148003)[36])[12])[24] - 1
((char*)&((char*)$unknown_148003)[36])[20]' = ((char*)&((char*)$unknown_148003)[36])[20] - 1
((char*)$unknown_148009)[4]' = ((char*)&$unknown_148009)[4]
((char*)$unknown_148009)[4]' = $unknown_148009
$unknown_148003' is freed
errno' != 0
freepmsgs.m_link' = &freepmsgs.m_link
freepmsgs.m_rlink' = &freepmsgs.m_link
hh' = 1
hostertid' = 0
hp' = hosts->ht_hosts[1]
mp' = &$unknown_148009
mpd' = 0
numpmsgs' = 0
pvmtracer.trctid' = 0
pvmtracer.outctx' = 0
pvmtracer.outtag' = 0
pvmtracer.trcbuf' = 0
pvmtracer.trcopt' = 0
strlen(&pvmtracer.tmask[0])' != 0
pvmtracer.trcctx' = 0
pvmtracer.tmask[35]' = 0
pvmtracer.trctag' = 0
pvmtracer.outtid' = 0
taskertid' = 0
tev_init_mask_i' = -1
wp' = waitlist
wp2' = &$unknown_148003




Change Warning 82.28672 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: