home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / gnu / gcc / bug / 2188 < prev    next >
Encoding:
Internet Message Format  |  1992-08-25  |  14.2 KB

  1. Path: sparky!uunet!stanford.edu!ames!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!lookout.IT.USwc.USwest.COM!dir
  2. From: dir@lookout.IT.USwc.USwest.COM (Daniel I. Rosenblatt)
  3. Newsgroups: gnu.gcc.bug
  4. Subject: gcc 2.2.2 w/-O4 corrupts diff-1.15
  5. Message-ID: <199208251631.AA09439@lookout.it.uswc.uswest.com>
  6. Date: 25 Aug 92 04:31:18 GMT
  7. Sender: gnulists@ai.mit.edu
  8. Distribution: gnu
  9. Organization: GNUs Not Usenet
  10. Lines: 336
  11. Approved: bug-gcc@prep.ai.mit.edu
  12.  
  13. I've got a Sun 4/670 running SunOS 4.1.2
  14. gcc 2.2.2 was built with 'configure sparc'.
  15. Compiling diff-1.15 with gcc 2.2.2 and -O4 will, with certain input files to
  16. diff, cause diff to core dump.  Recompiling the module analyze.c without
  17. optimization or with only simple optimization (-O) corrects the problem.  Here
  18. is a terminal session showing the problem (including the diff input files):
  19. ----------------------------------------------------------------------
  20. Script started on Tue Aug 25 10:19:30 1992
  21. kmongo_jr% gdiff x y >/dev/null
  22. kmongo_jr% bdiff x y >/dev/null
  23. Segmentation fault (core dumped)
  24. kmongo_jr% gdb bdiff core
  25. GDB is free software and you are welcome to distribute copies of it
  26.  under certain conditions; type "show copying" to see the conditions.
  27. There is absolutely no warranty for GDB; type "show warranty" for details.
  28. GDB 4.6, Copyright 1992 Free Software Foundation, Inc...
  29. Core was generated by `bdiff'.
  30. Program terminated with signal 11, Segmentation fault.
  31. #0  0x38f4 in diag (xoff=7, xlim=22, yoff=7, ylim=26, cost=0xf7fff7dc)
  32.     at analyze.c:93
  33. 93      bd[bmid] = xlim;
  34. (gdb) where
  35. #0  0x38f4 in diag (xoff=7, xlim=22, yoff=7, ylim=26, cost=0xf7fff7dc)
  36.     at analyze.c:93
  37. #1  0x3fdc in compareseq (xoff=7, xlim=22, yoff=7, ylim=26) at analyze.c:266
  38. #2  0x401c in compareseq (xoff=7, xlim=73, yoff=7, ylim=82) at analyze.c:289
  39. #3  0x4b50 in diff_2_files (filevec=0xf7fff970, depth=0) at analyze.c:792
  40. #4  0x37a8 in compare_files (dir0=0x0, name0=0xf7fffbee "x", dir1=0x0, 
  41.     name1=0xf7fffbf0 "y", depth=0) at diff.c:664
  42. #5  0x2c54 in main (argc=3, argv=0xf7fffb9c) at diff.c:392
  43. (gdb) quit
  44. kmongo_jr% cat x
  45. int MRHierarchyMgr::GetNextPage( MRPageReqPtr curPageInfo )
  46. {
  47.    int           retVal = FALSE;               /* return value */
  48.    long          lastPage = -1,                /* last page of file */
  49.                  nextFile = -1,                /* id of next file in order */
  50.          nextFileView = -1,            /* if of view for nextFile */
  51.          nextFileDoc = -1;             /* id of doc for nextFile */
  52.    
  53.       {
  54.       /* get the sequence number of the last page in the cur page's file */
  55.       if( ( lastPage = GetFileLastPageNum( curTocParent, curPageInfo->fileId, 
  56.                     curPageInfo->docId ) ) == -1 )
  57.          LogError( "GetFileLastPageNum failed in MRHierarchyMgr::GetNextPage",
  58.                NULL, 0, USER_ERROR );      
  59.          
  60.       /* if at end of file, find the next file */
  61.       else if( ( ( curPageInfo->pageSeq + 1 ) > lastPage ) &&
  62.                !FindNextFile( curTocParent, curPageInfo->fileId, 
  63.                               curPageInfo->docId, curPageInfo->viewId,
  64.                               &nextFile, &nextFileDoc, &nextFileView ) )
  65.          LogError( "FindNextFile failed in MRHierarchyMgr::GetNextPage",
  66.                    NULL, 0, USER_ERROR );      
  67.          
  68.       /* get the next page if there is one */
  69.       else
  70.          {
  71.          /* at end of file and no more files, tell the gui */
  72.          if( ( ( curPageInfo->pageSeq + 1 ) > lastPage ) && 
  73.              ( nextFile == -1 ) )
  74.             {
  75.             if( !AsyncSendToObjs( DMPMSG_OBJ_TO_OBJ_MSG, 
  76.                                   DMPMSG_NUM_NO_MORE_PAGES, 
  77.                                     (void *)NULL, 0 ) )
  78.                LogError( "AsyncSendToObjs failed in MRHierMgr::GetNextPage",
  79.                          NULL, 0, USER_ERROR );
  80.             else
  81.                retVal = TRUE;
  82.            }
  83.    
  84.          /* is a page, so get it */
  85.          else
  86.             {
  87.             /* if new file, load the new file and doc into the structure */
  88.             if( ( curPageInfo->pageSeq + 1 ) > lastPage )
  89.                {
  90.               curPageInfo->fileId  = nextFile;
  91.               curPageInfo->docId   = nextFileDoc;
  92.               curPageInfo->viewId  = nextFileView;
  93.               curPageInfo->pageSeq = 1;
  94.                }
  95.         
  96.             /* if same file, increment sequence */
  97.             else
  98.               curPageInfo->pageSeq++;
  99.    
  100.             /* set defaults */
  101.             curPageInfo->rotation   = defaultRotation;
  102.             curPageInfo->scale      = defaultScale;
  103.             curPageInfo->screenWid  = defaultScreenWid;
  104.             curPageInfo->screenHt   = defaultScreenHt;
  105.             curPageInfo->printFlg   = FALSE;
  106.             curPageInfo->hiWords    = NULL;
  107.             curPageInfo->numHiWords = 0;
  108.    
  109.             if( curPageInfo->pagePath )
  110.                {
  111.                delete curPageInfo->pagePath;
  112.                curPageInfo->pagePath = NULL;
  113.                }
  114.         
  115.             /* get the toc index for the page & add it to the page structure */
  116.             if( !AddPageTocIndex( curPageInfo ) )
  117.                LogError( "AddPageTocIndex failed in MRHierMgr::GetNextPage",
  118.                          NULL, 0, USER_ERROR );
  119.            
  120.             /* add the path to the page */
  121.             else if( !BuildPagePath( curPageInfo ) )
  122.                LogError( "BuildPagePath failed in MRHierMgr::GetNextPage",
  123.                          NULL, 0, USER_ERROR );     
  124.    
  125.             /* add the descr and get the page */
  126.             else
  127.               {
  128.                strncpy( curPageInfo->pageDescr, 
  129.                         mrHierList[ curPageInfo->hierIndex ].
  130.                         toc[ curPageInfo->tocIndex ].descr, 
  131.                         MR_HIER_MAX_STRING_SIZE - 1 );
  132.                curPageInfo->pageDescr[ MR_HIER_MAX_STRING_SIZE - 1 ] = '\0';
  133.          
  134.                  /* send the page request */
  135.                if( !SendToObjs( DMPMSG_OBJ_TO_OBJ_MSG, DMPMSG_NUM_GET_PAGE, 
  136.                                 (void *)curPageInfo, sizeof( MRPageReqRec ), 
  137.                        FALSE ) )
  138.                   LogError( "SendToObjs failed in MRHierMgr::GetNextPage",
  139.                             NULL, 0, USER_ERROR );
  140.            
  141.                 else
  142.                   retVal = TRUE;
  143.            
  144.                }  /*  end else add the descr and get the page */
  145.         
  146.            }  /*  end else is a page, so get it */
  147.       
  148.          }  /*  end else get the next page if there is one */
  149.  
  150.       } /* end if the current TOC matches the page requested */
  151.  
  152.    /* if the current TOC does not match the page's go request it */
  153.    else
  154.        /* end else the current TOC does not match */
  155.  
  156.    return retVal;
  157.    
  158. }  /*  end GetNextPage  */
  159. kmongo_jr% cat y
  160. int MRHierarchyMgr::GetNextPage( MRPageReqPtr curPageInfo )
  161. {
  162.    char          buf[256];                     /* message buffer for errors */
  163.    int           pagesLeft = 0;                /* number pages actually avail */
  164.    int           error = FALSE;                /* denotes an error in paging */
  165.    int           reqPageOffset = 0;            /* compute page offset to get */
  166.    int           retVal = FALSE;               /* return value */
  167.    long          lastPage = -1,                /* last page of file */
  168.                  nextFile = -1,                /* id of next file in order */
  169.          nextFileView = -1,            /* id of view for nextFile */
  170.          nextFileDoc = -1,             /* id of doc for nextFile */
  171.                  rtnNextFile = -1,             /* rtn'd file id */
  172.          rtnNextFileView = -1,         /* rtn'd view id */
  173.          rtnNextFileDoc = -1;          /* rtn'd doc id */
  174.    
  175.       {
  176.       /* grab the number of pages requested */
  177.       reqPageOffset = curPageInfo->pageOffset;
  178.  
  179.       /* get the sequence number of the last page in the cur page's file */
  180.       if( ( lastPage = GetFileLastPageNum( curTocParent, curPageInfo->fileId, 
  181.                     curPageInfo->docId ) ) == -1 )
  182.          LogError( "GetFileLastPageNum failed in MRHierarchyMgr::GetNextPage",
  183.                NULL, 0, USER_ERROR );      
  184.  
  185.       else 
  186.          {
  187.          /* if the requested page is not in the current file, try to */
  188.          /* page through and find the appropriate file */
  189.          if( ( curPageInfo->pageSeq + reqPageOffset ) > lastPage )
  190.             {
  191.             nextFile = curPageInfo->fileId;
  192.             nextFileDoc = curPageInfo->docId;
  193.             nextFileView = curPageInfo->viewId;
  194.    
  195.             do
  196.                {
  197.                /* if we are on the first file, then subtract off number */
  198.                /* of pages remaining, otherwise subtract number of pages */
  199.                /* in the file */
  200.                if( nextFile == curPageInfo->fileId )
  201.                   {
  202.                   reqPageOffset -= (int) lastPage - curPageInfo->pageSeq;
  203.                   pagesLeft = (int) lastPage - curPageInfo->pageSeq;
  204.                   }
  205.                else
  206.                   {
  207.                   reqPageOffset -=  (int) lastPage;
  208.                   pagesLeft += (int) lastPage;
  209.                   }
  210.  
  211.                /* go get the next file */
  212.                if( ( !FindNextFile( curTocParent, nextFile, 
  213.                                   nextFileDoc, nextFileView, &rtnNextFile, 
  214.                                   &rtnNextFileDoc, &rtnNextFileView ) ) ||
  215.                    ( rtnNextFile == -1 ) )
  216.                   {
  217.                   error = TRUE;
  218.                   }
  219.  
  220.                /* find out how many pages in next file */
  221.                else if( ( lastPage = GetFileLastPageNum( curTocParent, 
  222.                                         rtnNextFile, rtnNextFileDoc ) ) == -1 )
  223.                   {
  224.                   error = TRUE;
  225.                   }
  226.  
  227.                nextFile = rtnNextFile;
  228.                nextFileDoc = rtnNextFileDoc;
  229.                nextFileView = rtnNextFileView;
  230.                }
  231.  
  232.                /* Add 1 to test for last page in case seq number was a zero. */
  233.                /* If requested page in this file or if there was an error, */
  234.                /* we're done, else keep trying to find the file */
  235.             while( ( reqPageOffset >= lastPage + 1 ) && ( !error ) );
  236.  
  237.             /* if there was an error (including if there were not enough */
  238.             /* pages to satisfy the request) send a msg and display warning */
  239.             if( error )
  240.                {
  241.                if( !AsyncSendToObjs( DMPMSG_OBJ_TO_OBJ_MSG, 
  242.                                      DMPMSG_NUM_NO_MORE_PAGES, 
  243.                                      (void *)NULL, 0 ) )
  244.                   LogError( "AsyncSendToObjs failed in MRHierMgr::GetNextPage",
  245.                             NULL, 0, USER_ERROR );
  246.                else
  247.                   {
  248.                   if( pagesLeft <= 0 )
  249.                      sprintf( buf, "There are no more pages available.\n" );
  250.                   else if( pagesLeft == 1 )
  251.                      sprintf( buf, "There is only one more page available.\n" );
  252.                   else
  253.                      sprintf( buf, "There are only %d more pages available.\n",
  254.                               pagesLeft );
  255.  
  256.                   if ( !AsyncSendToObjs( DMPMSG_OBJ_TO_OBJ_MSG,
  257.                                          DMPMSG_NUM_DISPLAY_WARNING,
  258.                                          buf, strlen( buf ) + 1 ) )
  259.                      LogError( "AsyncSendToObjs failed in MRHierMgr::GetNextPg",
  260.                                NULL, 0, USER_ERROR );
  261.  
  262.                   else 
  263.                      retVal = TRUE;
  264.                   }
  265.                }
  266.             else  
  267.                {
  268.                /* save info about file we want to retrieve the requested page */
  269.                curPageInfo->fileId  = rtnNextFile;
  270.                curPageInfo->docId   = rtnNextFileDoc;
  271.                curPageInfo->viewId  = rtnNextFileView;
  272.                curPageInfo->pageSeq = reqPageOffset;
  273.                }
  274.            }
  275.         
  276.          /* else the page is in the current file, increment sequence */
  277.          else
  278.             curPageInfo->pageSeq += reqPageOffset;
  279.    
  280.          /* if there were no errors, go make the page request */
  281.          if( !error )
  282.             {
  283.             /* set defaults */
  284.             curPageInfo->rotation   = defaultRotation;
  285.             curPageInfo->scale      = defaultScale;
  286.             curPageInfo->screenWid  = defaultScreenWid;
  287.             curPageInfo->screenHt   = defaultScreenHt;
  288.             curPageInfo->printFlg   = FALSE;
  289.             curPageInfo->hiWords    = NULL;
  290.             curPageInfo->numHiWords = 0;
  291.          
  292.             if( curPageInfo->pagePath )
  293.                {
  294.                delete curPageInfo->pagePath;
  295.                curPageInfo->pagePath = NULL;
  296.                }
  297.         
  298.             /* get the toc index for the page & add it to the page structure */
  299.             if( !AddPageTocIndex( curPageInfo ) )
  300.                LogError( "AddPageTocIndex failed in MRHierMgr::GetNextPage",
  301.                          NULL, 0, USER_ERROR );
  302.            
  303.             /* add the path to the page */
  304.             else if( !BuildPagePath( curPageInfo ) )
  305.                LogError( "BuildPagePath failed in MRHierMgr::GetNextPage",
  306.                          NULL, 0, USER_ERROR );     
  307.    
  308.             /* add the descr and get the page */
  309.             else
  310.               {
  311.                strncpy( curPageInfo->pageDescr, 
  312.                         mrHierList[ curPageInfo->hierIndex ].
  313.                         toc[ curPageInfo->tocIndex ].descr, 
  314.                         MR_HIER_MAX_STRING_SIZE - 1 );
  315.                curPageInfo->pageDescr[ MR_HIER_MAX_STRING_SIZE - 1 ] = '\0';
  316.          
  317.                  /* send the page request */
  318.                if( !SendToObjs( DMPMSG_OBJ_TO_OBJ_MSG, DMPMSG_NUM_GET_PAGE, 
  319.                                 (void *)curPageInfo, sizeof( MRPageReqRec ), 
  320.                        FALSE ) )
  321.                   LogError( "SendToObjs failed in MRHierMgr::GetNextPage",
  322.                             NULL, 0, USER_ERROR );
  323.            
  324.                 else
  325.                   retVal = TRUE;
  326.            
  327.                }  /*  end else add the descr and get the page */
  328.  
  329.             } /* if there were no errors */
  330.  
  331.          } /* we were able to determine end of current file */
  332.  
  333.       } /* end if the current TOC matches the page requested */
  334.  
  335.    /* if the current TOC does not match the page's go request it */
  336.    else
  337.        /* end else the current TOC does not match */
  338.  
  339.    return retVal;
  340.    
  341. }  /*  end GetNextPage  */
  342. kmongo_jr% exit
  343. script done on Tue Aug 25 10:24:11 1992
  344.  
  345.  
  346. I can be reached at
  347. dir@lookout.uswest.com
  348. 303/595-2854
  349.