Subject: bug#77840: [bug-diffutils] bug#77840: Testing diffutils 3.12 on PPC Mac OS X 10.4.11, Tiger, produces so many failures

From: Peter Dyballa <[email-masked]>
Date: Sun, 22 Jun 2025 10:35:46 +0200

Hello Paul!

The differences start earlier:

	Breakpoint 1 at 0xf1ac: file diff.c, line 1633.
	Breakpoint 2 at 0x8e10: file context.c, line 349.
	Breakpoint 3 at 0x69f4: file analyze.c, line 624.
	Breakpoint 4 at 0x6a04: file analyze.c, line 628.
	Breakpoint 5 at 0x82f4: file context.c, line 123.
	Breakpoint 6 at 0x8fa8: file context.c, line 379.
	Breakpoint 7 at 0x222e4: file util.c, line 989.
	Breakpoint 8 at 0x2244c: file util.c, line 1028.
	
	Breakpoint 1, compare_files (parent=0x61000, detype=0x5e2b4, name0=0xbfffd8a1 "Portfile-graphite2-312", name1=0xbfffd8b8 "Portfile-graphite2") at diff.c:1633
	(gdb) n, step
	compare_prepped_files (parent=0x61000, cmp=0xbfffd218, open_flags=1073741824) at diff.c:1167
	(gdb) cont
	Breakpoint 4, diff_2_files (cmp=0xbfffd218) at analyze.c:628
	(gdb) p *script
	$1 = {
	  link = 0x0, 
	  inserted = 17, 
	  deleted = 8, 
	  line0 = -1, 
	  line1 = -10, 
	  ignore = true
	}

This was on PPC Mac OS X 10.4.11. On macOS High Sierra, Version 10.13.6, I get in the end:

	(gdb) p *script
	$1 = {
	  link = 0x0,
	  inserted = 1,
	  deleted = 1,
	  line0 = 3,
	  line1 = 3,
	  ignore = true
	}

On Tiger the computed different numbers lead to first0 = -4 and first1 = -13 and use of negative indexes in pr_unidiff_hunk(), context.c:376:

  363	  putc ('\n', out);		# prints line numbers header/label before the actual script
  364	
  365	  struct change *next = hunk;
  366	  lin i = first0;
  367	  lin j = first1;
  368	
  369	  while (i <= last0 || j <= last1)
  370	    {
  371	
  372	      /* If the line isn't a difference, output the context from file 0. */
  373	
  374	      if (!next || i < next->line0)
  375	        {
  376		  char const *const *line = &curr.file[0].linbuf[i++];
  377	          if (! (suppress_blank_empty && **line == '\n'))
  378	            putc (initial_tab ? '\t' : ' ', out);
  379	          print_1_line (nullptr, line);
  380	          j++;
  381	        }
  382	      else

Why are the values negative? Does this lead to defective struct curr or line? When does it start?

--
Greetings

  Pete

With Capitalism man exploits man. With communism it's the exact opposite.