Text  |   XML   |   Visible Warnings:

Pvm : Pvm analysis 1 : Null Pointer Dereference  at trcmess.c:768

Categories: LANG.MEM.NPD CWE:476
Warning ID: 2861.2925
Similar Warnings: 2861.2926
Procedure: trc_handle_trace_message
Trace: View
Modified: Wed Sep 2 12:50:43 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/tracer/trcmess.c
   Enter trc_handle_trace_message
 377 trc_handle_trace_message( ID, src ) 
 378 TRC_ID ID;
 379 int src;
 380 {
 381         TRC_DATADESC DD;
 382  
 383         TRC_TEVDESC TD;
 384  
 385         TRC_TEVTASK TT;
 386  
 387         TRC_HOST H;
   ...
 404         int tusec;
 405         int tsec;
 406         int ecnt;
 407         int eid;
 408         int tid;
 409         int dt;
 410  
 411         int marker;
 412         int nest;
 413  
 414         ecnt = 0;
 415  
 416         TRC_PVMCKERR( pvm_upkint( &marker, 1, 1 ),
 417                 "Unpacking Trace Message", return( ecnt ) );
 418  
 419         /* Old PVM 3.3 Trace Format */ 
 420  
 421         if ( marker > 0 )
 422         {
 423                 tsec = marker;
 424  
 425                 TRC_PVMCKERR( pvm_upkint( &tusec, 1, 1 ),
 426                         "Event Parse Error", return( ecnt ) );
 427  
 428                 TRC_PVMCKERR( pvm_upkint( &tid, 1, 1 ),
 429                         "Event Parse Error", return( ecnt ) );
 430  
 431                 TRC_PVMCKERR( pvm_upkint( &eid, 1, 1 ),
   ...
 433  
 434                 ecnt += trc_store_old_trace_event( ID, tsec, tusec, tid, eid );   /* Uninitialized Variable (ID: 2863.2928) */
 435  
 436                 return( ecnt );
 437         }
 438  
 439         /* New PVM 3.4 Format */ 
 440  
 441         /* Get Task & Host Info */ 
 442  
 443         TT = trc_get_tevtask_tid( ID, src );
 444  
 445         pvmd_tid = pvm_tidtohost( src );
 446  
 447         if ( !pvmd_tid )
 448                 pvmd_tid = pvm_tidtohost( TRC_TID );
 449  
 450         H = trc_get_host_tid( pvmd_tid );
 451  
 452         /* Set Leftover Event Omit Flag */ 
 453  
 454         omit = ( ID->trace_out == NULL 
true455                 || ( TT != NULL && TRC_TASK_OMIT( TT ) ) ) 
 456                         ? TRC_TRUE : TRC_FALSE;
 457  
 458         /* Process Event Message */ 
 459  
 460         nest = 0;
 461  
 462         done = 0;
 463  
 464         do 
 465         {
 466                 switch ( marker ) 
 467                 {
 468                         case TEV_MARK_EVENT_BUFFER: 
 469                         {
 470                                 nest++;
 471  
 472                                 break;
 473                         }
 474  
 475                         case TEV_MARK_EVENT_BUFFER_END: 
 476                         {
 477                                 if ( !(--nest) )
 478                                         done++;
 479  
 480                                 break;
 481                         }
 482  
 483                         case TEV_MARK_DATA_ID: 
 484                         {
 485                                 did_done = 0;
 486  
 487                                 do 
 488                                 {
 489                                         TRC_PVMCKERR( pvm_upkint( &did_int, 1, 1 ),
 490                                                 "Data ID Message", return( ecnt ) );
 491  
 492                                         if ( did_int != TEV_MARK_DATA_ID_END )
 493                                         {
 494                                                 TRC_PVMCKERR( pvm_upkstr( did ),
 495                                                         "Data ID Name", return( ecnt ) );
 496  
 497                                                 TRC_PVMCKERR( pvm_upkstr( diddesc ),
 498                                                         "Data ID Description", return( ecnt ) );
 499  
 500                                                 dptr = (TRC_DID) trc_lookup_trie( TRC_DID_TRIE,
 501                                                         did );
 502  
 503                                                 if ( dptr == NULL 
 504                                                         || dptr->id != did_int 
 505                                                         || strcmp( dptr->desc, diddesc ) )
 506                                                 {
 507                                                         dptr = trc_create_did();
 508  
 509                                                         dptr->id = did_int;
 510  
 511                                                         dptr->name = trc_copy_str( did );
 512  
 513                                                         dptr->desc = trc_copy_str( diddesc );
 514  
 515                                                         dptr->next = TRC_DID_LIST;
 516  
 517                                                         TRC_DID_LIST = dptr;
 518  
 519                                                         trc_add_to_trie( TRC_DID_TRIE,
 520                                                                 dptr->name, (void *) dptr );
 521                                                 }
 522  
 523                                                 trc_set_didlist( H, dptr );
 524                                         }
 525  
 526                                         else 
 527                                                 did_done++;
 528                                 }
 529                                 while ( !did_done );
 530  
 531                                 if ( !nest )
 532                                         done++;
 533  
 534                                 break;
 535                         }
 536  
 537                         case TEV_MARK_EVENT_DESC: 
 538                         {
 539                                 TD = trc_create_tevdesc();   /* Leak (ID: 2859.2923) */
 540  
 541                                 TD->refcount = 1;
 542  
 543                                 TRC_PVMCKERR( pvm_upkint( &eid, 1, 1 ),
 544                                         "Event Descriptor ID", return( ecnt ) );
 545  
 546                                 TD->eid = eid & ~( TEV_EVENT_ENTRY | TEV_EVENT_EXIT );
 547  
 548                                 if ( eid & TEV_EVENT_ENTRY )
 549                                         TD->entry_exit = TRC_ENTRY_TEV;
 550  
 551                                 else if ( eid & TEV_EVENT_EXIT )
 552                                         TD->entry_exit = TRC_EXIT_TEV;
 553  
 554                                 else 
 555                                         TD->entry_exit = TRC_IGNORE_TEV;
 556  
 557                                 TRC_PVMCKERR( pvm_upkstr( tmp ),
 558                                         "Event Descriptor Name", return( ecnt ) );
 559  
 560                                 TD->name = trc_copy_str( tmp );
 561  
 562                                 desc_done = 0;
 563  
 564                                 do 
 565                                 {
 566                                         TRC_PVMCKERR( pvm_upkint( &did_int, 1, 1 ),
 567                                                 "Semantic Data ID", return( ecnt ) );
 568  
 569                                         if ( did_int != TEV_MARK_EVENT_DESC_END )
 570                                         {
 571                                                 if ( TD->ddesc == NULL )
 572                                                         DD = TD->ddesc = trc_create_datadesc();
 573  
 574                                                 else 
 575                                                         DD = DD->next = trc_create_datadesc();
 576  
 577                                                 if ( H->didlist == NULL )   /* Null Pointer Dereference (ID: 2860.2924) */
 578                                                 {
 579                                                         printf( 
 580                                                         "Warning: Missing DID List For Host %s\n",
 581                                                                 H->name );
 582                                                 }
 583  
 584                                                 DD->did = trc_get_did( H, did_int );
 585  
 586                                                 if ( DD->did == NULL )
 587                                                 {
 588                                                         printf( "Error: DID=%d Not Found\n",
 589                                                                 did_int );
 590  
 591                                                         trc_free_tevdesc( &TD );
 592  
 593                                                         return( ecnt );
 594                                                 }
 595  
 596                                                 TRC_PVMCKERR( pvm_upkint( &dt, 1, 1 ),
 597                                                         "Data Type", return( ecnt ) );
 598  
 599                                                 DD->dt = dt & 
 600                                                         ~( TEV_DATA_SCALAR | TEV_DATA_ARRAY );
 601  
 602                                                 DD->array = dt & 
 603                                                         ( TEV_DATA_SCALAR | TEV_DATA_ARRAY );
 604  
 605                                                 if ( !trc_unpack_data_value( DD ) )
 606                                                 {
 607                                                         trc_free_tevdesc( &TD );
 608  
 609                                                         return( ecnt );
 610                                                 }
 611                                         }
 612  
 613                                         else 
 614                                                 desc_done++;
 615                                 }
 616                                 while ( !desc_done );
 617  
 618                                 dump_event = trc_add_tevdesc( ID, &TD, src, omit );
 619  
 620                                 trc_set_tevlist( TT, H, TD );
 621  
 622                                 if ( TD->dump )
 623                                         trc_dump_tevdesc( ID, TD, src );
 624  
 625                                 if ( dump_event )
 626                                         trc_store_data_values( ID, TD, src, omit );
 627  
 628                                 if ( !omit )
 629                                         ecnt++;
 630  
 631                                 if ( !nest )
 632                                         done++;
 633  
 634                                 break;
 635                         }
 636  
 637                         case TEV_MARK_USER_EVENT_RECORD: 
 638                         {
 639                                 TD = trc_create_tevdesc();   /* Leak (ID: 2859.2922) */
 640  
 641                                 TD->refcount = 1;
 642  
 643                                 TRC_PVMCKERR( pvm_upkint( &eid, 1, 1 ),
 644                                         "Event Descriptor ID", return( ecnt ) );
 645  
 646                                 TD->eid = eid & ~( TEV_EVENT_ENTRY | TEV_EVENT_EXIT );
 647  
 648                                 if ( eid & TEV_EVENT_ENTRY )
 649                                         TD->entry_exit = TRC_ENTRY_TEV;
 650  
 651                                 else if ( eid & TEV_EVENT_EXIT )
 652                                         TD->entry_exit = TRC_EXIT_TEV;
 653  
 654                                 else 
 655                                         TD->entry_exit = TRC_IGNORE_TEV;
 656  
 657                                 TRC_PVMCKERR( pvm_upkstr( tmp ),
 658                                         "Event Descriptor Name", return( ecnt ) );
 659  
 660                                 TD->name = trc_copy_str( tmp );
 661  
 662                                 /* Yank Out Hardwired Timestamp */ 
 663  
 664                                 DD = TD->ddesc = trc_create_datadesc();
 665  
 666                                 DD->did = trc_get_did( (TRC_HOST) NULL, TEV_DID_TS );
 667  
 668                                 DD->dt = TEV_DATA_INT;
 669                                 DD->array = TEV_DATA_SCALAR;
 670  
 671                                 if ( !trc_unpack_data_value( DD ) )
 672                                 {
 673                                         trc_free_tevdesc( &TD );
 674  
 675                                         return( ecnt );
 676                                 }
 677  
 678                                 DD = DD->next = trc_create_datadesc();
 679  
 680                                 DD->did = trc_get_did( (TRC_HOST) NULL, TEV_DID_TU );
 681  
 682                                 DD->dt = TEV_DATA_INT;
 683                                 DD->array = TEV_DATA_SCALAR;
 684  
 685                                 if ( !trc_unpack_data_value( DD ) )
 686                                 {
 687                                         trc_free_tevdesc( &TD );
 688  
 689                                         return( ecnt );
 690                                 }
 691  
 692                                 desc_done = 0;
 693  
 694                                 do 
 695                                 {
 696                                         TRC_PVMCKERR( pvm_upkint( &dt, 1, 1 ),
 697                                                 "Data Type", return( ecnt ) );
 698  
 699                                         if ( dt != TEV_MARK_USER_EVENT_RECORD_END )
 700                                         {
 701                                                 DD = DD->next = trc_create_datadesc();
 702  
 703                                                 DD->dt = dt & 
 704                                                         ~( TEV_DATA_SCALAR | TEV_DATA_ARRAY );
 705  
 706                                                 DD->array = dt & 
 707                                                         ( TEV_DATA_SCALAR | TEV_DATA_ARRAY );
 708  
 709                                                 if ( !trc_unpack_data_value( DD ) )
 710                                                 {
 711                                                         trc_free_tevdesc( &TD );
 712  
 713                                                         return( ecnt );
 714                                                 }
 715                                         }
 716  
 717                                         else 
 718                                                 desc_done++;
 719                                 }
 720                                 while ( !desc_done );
 721  
 722                                 dump_event = trc_add_tevdesc( ID, &TD, src, omit );
 723  
 724                                 if ( TD->dump )
 725                                         trc_dump_tevdesc( ID, TD, src );
 726  
 727                                 if ( dump_event )
 728                                         trc_store_data_values( ID, TD, src, omit );
 729  
 730                                 if ( !omit )
 731                                         ecnt++;
 732  
 733                                 if ( !nest )
 734                                         done++;
 735  
 736                                 break;
 737                         }
 738  
 739                         case TEV_MARK_EVENT_RECORD: 
 740                         {
 741                                 TRC_PVMCKERR( pvm_upkint( &eid, 1, 1 ),
 742                                         "Event ID", return( ecnt ) );
 743  
 744                                 if ( eid & TEV_EVENT_ENTRY )
 745                                         entry_exit = TRC_ENTRY_TEV;
 746  
 747                                 else if ( eid & TEV_EVENT_EXIT )
 748                                         entry_exit = TRC_EXIT_TEV;
 749  
 750                                 else 
 751                                         entry_exit = TRC_IGNORE_TEV;
 752  
 753                                 eid &= ~( TEV_EVENT_ENTRY | TEV_EVENT_EXIT );
 754  
 755                                 TD = trc_get_tevdesc( TT, H, eid, entry_exit );
 756  
 757                                 if ( TD != NULL )
 758                                 {
 759                                         if ( trc_store_trace_event( ID, TD, src, omit ) )
 760                                                 ecnt++;
 761                                 }
 762  
 763                                 else 
 764                                 {
 765                                         printf( 
 766                                                 "Error: Event ID %d(%d) %s T(%d/%x) H(%d/%x)\n",
 767                                                 eid, entry_exit, "Descriptor Not Found",
TT <= 4095768                                                 TT->tid, TT->tid, H->pvmd_tid, H->pvmd_tid );     /* Null Pointer Dereference */
 769                                 }
 770  
 771                                 if ( !nest )
 772                                         done++;
 773  
 774                                 break;
 775                         }
 776                 }
 777  
 778                 if ( !done )
 779                 {
 780                         TRC_PVMCKERR( pvm_upkint( &marker, 1, 1 ),
 781                                 "Unpacking Trace Message", return( ecnt ) );
 782                 }
 783         }
 784         while ( !done );
Preconditions
((char*)$param_1)[24] >= 0
((char*)$param_1)[40] != 0
pvmrbuf != 0
pvmtoplvl != 0
Postconditions
H' = TRC_HOST_LIST
ID' = $param_1
TD' = 0
TRC_TMP_CC' = 0
TT' = 0
done' >= -1
done' <= 0
entry_exit' = 2
marker' = -7
omit' = 0
pvmd_tid' = TRC_HOST_LIST->pvmd_tid
pvmtrc.trctid' >= 1
pvmtrccodef' = &$unknown_2811473
src' = $param_2




Change Warning 2861.2925 : Null Pointer Dereference

Because they are very similar, this warning shares annotations with warning 2861.2926.

Priority:
State:
Finding:
Owner:
Note: