home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume7 / patch2 / patch4 / text0000.txt < prev   
Encoding:
Text File  |  1986-11-30  |  5.7 KB  |  196 lines

  1. [The latest patch for patch version 2.0 is #5.]
  2.  
  3. mailpatch speaking for lwall
  4.  
  5. System: patch version 2.0
  6. Patch #: 4
  7. Priority: HIGH
  8. Subject: Certain long hunks are not dynamically allocated correctly
  9. From: Herb Chong and Hokey
  10.  
  11. Description:
  12.     If the pattern portion of a hunk is longer than the initially
  13.     allocated maximum hunk size, the hunk is not grown larger in time.
  14.     The malloc arena gets stomped on non-4bsd sites.  4bsd sites
  15.     generally survive this because more memory is generally allocated
  16.     than you asked for.
  17.  
  18.     There was also a minor difficulty with error numbers on new-style
  19.     context diffs that require backtracking to parse correctly because
  20.     the input line number was not reset along with the file position.
  21.     Note that backtracking is VERY rare--you have to have a patch
  22.     that ends with a deletion, so that the replacement text is missing,
  23.     and at least one line at the place where the replacement text WOULD
  24.     have been must look like a replacement line.  Only then does
  25.     backtracking occur.  (Backtracking would be entirely unnecessary
  26.     if patches were unambiguously terminated, but they aren't.  Note
  27.     that the version of patch that comes with 4.3bsd doesn't backtrack
  28.     at all.)
  29.  
  30. Repeat-By:
  31.     Compile up patch with a version of malloc that doesn't round up
  32.     to a power of two.  Apply a patch with more than 125 lines in
  33.     the pattern (not the replacement) part of the hunk.  Run patch
  34.     and watch the fireworks.  Delete the core dump.
  35.  
  36. Fix:    From rn, say "| patch -d DIR", where DIR is your patch source
  37.     directory.  Outside of rn, say "cd DIR; patch <thisarticle".
  38.     If you don't have the patch program, apply the following by hand,
  39.     or get patch.
  40.  
  41.     If patch indicates that patchlevel is the wrong version, you may need
  42.     to apply one or more previous patches, or the patch may already
  43.     have been applied.  See the patchlevel.h file to find out what has or
  44.     has not been applied.  In any event, don't continue with the patch.
  45.  
  46.     If you are missing previous patches they can be obtained from me:
  47.  
  48.     Larry Wall
  49.     {allegra,burdvax,cbosgd,hplabs,ihnp4,sdcsvax}!sdcrdcf!lwall
  50.  
  51.     If you send a mail message of the following form it will greatly speed
  52.     processing:
  53.  
  54.     Subject: Command
  55.     @SH mailpatch PATH patch 2.0 NUM ...
  56.  
  57.     where PATH is a return path FROM ME TO YOU in bang notation, and NUM
  58.     is the number of one or more patches you need, separated by spaces.
  59.     You can also get them by anonymous FTP from sdc-camarillo.arpa.
  60.  
  61. Index: patchlevel.h
  62. Prereq: 3
  63. 1c1
  64. < #define PATCHLEVEL 3
  65. ---
  66. > #define PATCHLEVEL 4
  67.  
  68. Index: pch.c
  69. Prereq: 2.0.1.2
  70. *** pch.c.old    Fri Nov 14 10:11:00 1986
  71. *** pch.c    Fri Nov 14 10:11:14 1986
  72. ***************
  73. *** 1,4
  74. ! /* $Header: pch.c,v 2.0.1.2 86/11/03 17:49:52 lwall Exp $
  75.    *
  76.    * $Log:    pch.c,v $
  77.    * Revision 2.0.1.2  86/11/03  17:49:52  lwall
  78.  
  79. --- 1,4 -----
  80. ! /* $Header: pch.c,v 2.0.1.3 86/11/14 10:08:33 lwall Exp $
  81.    *
  82.    * $Log:    pch.c,v $
  83.    * Revision 2.0.1.3  86/11/14  10:08:33  lwall
  84. ***************
  85. *** 1,6
  86.   /* $Header: pch.c,v 2.0.1.2 86/11/03 17:49:52 lwall Exp $
  87.    *
  88.    * $Log:    pch.c,v $
  89.    * Revision 2.0.1.2  86/11/03  17:49:52  lwall
  90.    * New-style delete triggers spurious assertion error.
  91.    * 
  92.  
  93. --- 1,10 -----
  94.   /* $Header: pch.c,v 2.0.1.3 86/11/14 10:08:33 lwall Exp $
  95.    *
  96.    * $Log:    pch.c,v $
  97. +  * Revision 2.0.1.3  86/11/14  10:08:33  lwall
  98. +  * Fixed problem where a long pattern wouldn't grow the hunk.
  99. +  * Also restored p_input_line when backtracking so error messages are right.
  100. +  * 
  101.    * Revision 2.0.1.2  86/11/03  17:49:52  lwall
  102.    * New-style delete triggers spurious assertion error.
  103.    * 
  104. ***************
  105. *** 401,406
  106.       bool repl_missing = FALSE;    /* we are now backtracking */
  107.       long repl_backtrack_position = 0;
  108.                       /* file pos of first repl line */
  109.       Reg7 LINENUM ptrn_copiable = 0;
  110.                       /* # of copiable lines in ptrn */
  111.   
  112.  
  113. --- 405,411 -----
  114.       bool repl_missing = FALSE;    /* we are now backtracking */
  115.       long repl_backtrack_position = 0;
  116.                       /* file pos of first repl line */
  117. +     LINENUM repl_patch_line;    /* input line number for same */
  118.       Reg7 LINENUM ptrn_copiable = 0;
  119.                       /* # of copiable lines in ptrn */
  120.   
  121. ***************
  122. *** 425,431
  123.           }
  124.           }
  125.           p_input_line++;
  126. !         p_char[++p_end] = *buf;
  127.           p_line[p_end] = Nullch;
  128.           switch (*buf) {
  129.           case '*':
  130.  
  131. --- 430,438 -----
  132.           }
  133.           }
  134.           p_input_line++;
  135. !         p_end++;
  136. !         assert(p_end < hunkmax);
  137. !         p_char[p_end] = *buf;
  138.           p_line[p_end] = Nullch;
  139.           switch (*buf) {
  140.           case '*':
  141. ***************
  142. *** 468,473
  143.               p_ptrn_lines = 0;
  144.               p_first = 1;
  145.           }
  146.           break;
  147.           case '-':
  148.           if (buf[1] == '-') {
  149.  
  150. --- 475,484 -----
  151.               p_ptrn_lines = 0;
  152.               p_first = 1;
  153.           }
  154. +         p_max = p_ptrn_lines + 6;    /* we need this much at least */
  155. +         while (p_max >= hunkmax)
  156. +             grow_hunkmax();
  157. +         p_max = hunkmax;
  158.           break;
  159.           case '-':
  160.           if (buf[1] == '-') {
  161. ***************
  162. *** 492,497
  163.               }
  164.               repl_beginning = p_end;
  165.               repl_backtrack_position = ftell(pfp);
  166.               p_line[p_end] = savestr(buf);
  167.               if (out_of_mem) {
  168.               p_end--;
  169.  
  170. --- 503,509 -----
  171.               }
  172.               repl_beginning = p_end;
  173.               repl_backtrack_position = ftell(pfp);
  174. +             repl_patch_line = p_input_line;
  175.               p_line[p_end] = savestr(buf);
  176.               if (out_of_mem) {
  177.               p_end--;
  178. ***************
  179. *** 601,606
  180.       if (repl_missing) {
  181.           
  182.           /* reset state back to just after --- */
  183.           for (p_end--; p_end > repl_beginning; p_end--)
  184.           free(p_line[p_end]);
  185.           Fseek(pfp, repl_backtrack_position, 0);
  186.  
  187. --- 613,619 -----
  188.       if (repl_missing) {
  189.           
  190.           /* reset state back to just after --- */
  191. +         p_input_line = repl_patch_line;
  192.           for (p_end--; p_end > repl_beginning; p_end--)
  193.           free(p_line[p_end]);
  194.           Fseek(pfp, repl_backtrack_position, 0);
  195.  
  196.