bugGNU roff - Bugs: bug #61206, [pic] causes stale input filename...

 
 

bug #61206: [pic] causes stale input filename to get cached

Submitter:  G. Branden Robinson <gbranden>
Submitted:  Thu 23 Sep 2021 07:17:20 AM UTC
   
 
Category:  Preprocessor pic Severity:  3 - Normal
Item Group:  Incorrect behaviour Status:  Fixed
Privacy:  Public Assigned to:  gbranden
Open/Closed:  Closed Planned Release:  1.23.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 28 Sep 2021 06:42:05 AM UTC, comment #2: 


commit 423e3c0b45a59c5476a2adc95bd38426a40456f3
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Tue Sep 28 16:05:36 2021 +1000

    [pic]: Update input file name correctly.

    * src/preproc/pic/troff.cpp (troff_output::set_location): Copy the
      inbound file name argument with `strdup()` and store pointer to this
      copy in `last_filename` instead of aliasing argument.

      (troff_output::~troff_output): `free()` the memory allocated by
      `strdup()` in destructor.

    Fixes <https://savannah.gnu.org/bugs/?61206>.  Pointer assignment
    instead of a string copy was being performed, which means that after its
    initial assignment, `last_filename` always shared its value ultimately
    with the `current_filename` pointer (a libgroff symbol), so `strcmp()`
    was always being performed on identical pointers.  Problem appears to
    date back 30+ years, to the dawn of our repo history.


G. Branden Robinson <gbranden>
Group administrator
Tue 28 Sep 2021 04:54:13 AM UTC, comment #1: 

Here's a simpler reproducer in raw roff, also demonstrating a fix in preparation.


$ cat EXPERIMENTS/pic1.roff
\en(.F is \n(.F
.br
$ ln EXPERIMENTS/pic1.roff EXPERIMENTS/pic2.roff
$ groff -p -T utf8 EXPERIMENTS/pic*roff | cat -s
\n(.F is EXPERIMENTS/pic1.roff
\n(.F is EXPERIMENTS/pic1.roff

$ ./build/test-groff -p -T utf8 EXPERIMENTS/pic*roff | cat -s
\n(.F is EXPERIMENTS/pic1.roff
\n(.F is EXPERIMENTS/pic2.roff


The output of pic is more revealing.


$ pic EXPERIMENTS/pic*.roff
.if !dPS .ds PS
.if !dPE .ds PE
.lf 1 EXPERIMENTS/pic1.roff
\en(.F is \n(.F
.br
.lf 1
\en(.F is \n(.F
.br
$ ./build/pic EXPERIMENTS/pic*.roff
.do if !dPS .ds PS
.do if !dPE .ds PE
.do if !dPF .ds PF
.lf 1 EXPERIMENTS/pic1.roff
\en(.F is \n(.F
.br
.lf 1 EXPERIMENTS/pic2.roff
\en(.F is \n(.F
.br


Observe the arguments to the second `lf` request in each case.
-verbatim-


G. Branden Robinson <gbranden>
Group administrator
Thu 23 Sep 2021 07:17:20 AM UTC, original submission:  

Reproducer:


$ cat EXPERIMENTS/manhose1.man
.TH manhose1 1 2021-09-23 "groff test suite"
.SH Name
manhose1 \- part 1 of two-piece hosefest
$ cat EXPERIMENTS/manhose2.man
.TH manhose2 1
.SH Name
manhose2 \- part 2 of two-piece hosefest
$ ./build/test-groff -z -ww -rCHECKSTYLE=3 -p -man EXPERIMENTS/manhose*
an.tmac:EXPERIMENTS/manhose1.man:1: style: .TH missing third argument; suggest document modification date in ISO 8601 format (YYYY-MM-DD)
an.tmac:EXPERIMENTS/manhose1.man:1: style: .TH missing fourth argument; suggest package/project name and version (e.g., "groff 1.23.0")


Note how the diagnostic thrown refers to the incorrect file.  The value of \n[.F] is wrong.  Taking out the `-p` option fixes it in this case.

G. Branden Robinson <gbranden>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by gbranden (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-09-28 gbranden StatusIn Progress Fixed
        Open/ClosedOpen Closed
        Planned ReleaseNone 1.23.0
    2021-09-28 gbranden StatusNone In Progress
        Assigned toNone gbranden

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code