bugGNU roff - Bugs: bug #64463, [groff] subroutine...

 
 

bug #64463: [groff] subroutine "debug_with_file_and_line" defined differently in two source files

Submitter:  Bjarni Ingi Gislason <bjarniig>
Submitted:  Mon 24 Jul 2023 12:46:24 AM UTC
   
 
Category:  Core Severity:  3 - Normal
Item Group:  Build/Installation Status:  Unreproducible
Privacy:  Public Assigned to:  None
Open/Closed:  Open Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 28 Jul 2023 12:12:11 AM UTC, comment #6: 

comment #4:

>   The Subject of the ticket is what matters.


This was addressed in comment #2: "This is deliberate."

>   Another result of the experiment was:


This seems unrelated to the current bug report and should be filed separately.

Dave <barx>
Group Member
Thu 27 Jul 2023 11:36:12 PM UTC, comment #5: 

comment #2:

> `debug_with_file_and_line` is newer.
>
> https://git.savannah.gnu.org/cgit/groff.git/commit/?id=93ffeffd21868f64af7302cb9574240c8354c60a


If anything, I think the significant thing here is that the info "There are no call sites for debug() [and debug_with_file_and_line()] and I don't plan for there to be; I am adding these for developer convenience" appears in the above commit message but in no code comments.  The name debug*() does hint at this aspect, but in general it's worthwhile to comment intentional dead code so that later code audits don't remove it.

Dave <barx>
Group Member
Thu 27 Jul 2023 09:32:20 PM UTC, comment #4: 

  The last paragraph in the ticket should not have been put there, as
this is a result of an experiment where the linker error is a side
effect.

  The Subject of the ticket is what matters.

  Another result of the experiment was:

  GROFF    contrib/hdtbl/examples/chess_board.ps
troff: warning: expected numeric expression, got character 'I'

  This is without any line information and comes from

src/roff/troff/number.cpp

  probably from subroutine

static bool is_valid_term(units *v, int scaling_unit,
                          bool is_parenthesized, bool is_mandatory)

  and

warning(WARN_NUMBER, "expected numeric expression, got %1",
        tok.description());

which reports neither file name nor line number.

  I won't repeat the experiment as it crashed the computer and I had to
repair the file system with "fsck" and a lot of pushing the return key.

Bjarni Ingi Gislason <bjarniig>
Tue 25 Jul 2023 05:57:04 AM UTC, comment #3: 

I can't reproduce any problem even if I add calls to the function (and its more ergonomic wrapper).  I added literals to make it clear which version of the functions (`troff` or `libgroff`'s) are being called.


diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index c808bc66c..fab876f8d 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -8299,6 +8299,8 @@ int main(int argc, char **argv)
   if (unsafe_flag)
     mac_path = &macro_path;
   set_string(".T", device);
+  debug_with_file_and_line("GBR", 1, "%1 %2 %3", "foo", "bar", "baz");
+  debug("qux");
   init_charset_table();
   init_hpf_code_table();
   if (0 /* nullptr */ == font::load_desc())
@@ -9056,7 +9058,7 @@ void debug_with_file_and_line(const char *filename,
                              const errarg &arg3)
 {
   if (program_name)
-    fprintf(stderr, "%s:", program_name);
+    fprintf(stderr, "GBRPREFIX:%s:", program_name);
   fprintf(stderr, "%s:", filename);
   if (lineno > 0)
     fprintf(stderr, "%d:", lineno);


I suspect the problem is with your private fork of groff.  If you can't reproduce the linker error with stock groff, this ticket should be closed as invalid.

G. Branden Robinson <gbranden>
Group administrator
Mon 24 Jul 2023 11:09:53 PM UTC, comment #2: 

original submission:

> Subject: [groff] subroutine "debug_with_file_and_line" defined
> differently in two source files
>
>   The files are
>
> libs/libgroff/error.cpp

>   and
>
> roff/troff/input.cpp


This is deliberate.  `troff`, the command, has always supplied its own versions of the diagnostic functions.

https://git.savannah.gnu.org/cgit/groff.git/tree/troff/input.c?h=1.02#n5694

https://git.savannah.gnu.org/cgit/groff.git/tree/lib/error.c?h=1.02#n29

`debug_with_file_and_line` is newer.

https://git.savannah.gnu.org/cgit/groff.git/commit/?id=93ffeffd21868f64af7302cb9574240c8354c60a

>   The subroutine in "roff/trof/input.cpp" is not used there and should
> be removed.


Neither version of `debug_with_file_and_line` should be in the execution trace of any shipping version of `groff`.  An optimizing linker could (should?) remove both symbols (along with both versions of `debug`) from each executable that it generates.  (libgroff.a is not shipped standalone and is only statically linked.)

>   A compilation of mine showed a linker error which disapered,
> when this subroutine was commented out.


I am interested to see this linker error.  Please provide it.

G. Branden Robinson <gbranden>
Group administrator
Mon 24 Jul 2023 03:16:03 PM UTC, comment #1: 

The output displays incorrectly because, not being in a "verbatim" block, some asterisks were interpreted as bold markup.  Reposting.

include/error.h:void debug_with_file_and_line(const char *, int, const char *,
include/error.h-                              const errarg & = empty_errarg,
include/error.h-                              const errarg & = empty_errarg,
include/error.h-                              const errarg & = empty_errarg);
include/error.h-
include/error.h-void fatal(const char *,
include/error.h-           const errarg & = empty_errarg,
include/error.h-           const errarg & = empty_errarg,
include/error.h-           const errarg & = empty_errarg);
include/error.h-
include/error.h-void error(const char *,
--
libs/libgroff/error.cpp:void debug_with_file_and_line(const char *filename,
libs/libgroff/error.cpp-                              int lineno,
libs/libgroff/error.cpp-                              const char *format,
libs/libgroff/error.cpp-                              const errarg &arg1,
libs/libgroff/error.cpp-                              const errarg &arg2,
libs/libgroff/error.cpp-                              const errarg &arg3)
libs/libgroff/error.cpp-{
libs/libgroff/error.cpp-  do_error_with_file_and_line(filename, 0 /* nullptr */, lineno,
libs/libgroff/error.cpp-                              DEBUG, format, arg1, arg2, arg3);
libs/libgroff/error.cpp-}
libs/libgroff/error.cpp-
--
roff/troff/input.cpp:void debug_with_file_and_line(const char *filename,
roff/troff/input.cpp-                         int lineno,
roff/troff/input.cpp-                         const char *format,
roff/troff/input.cpp-                         const errarg &arg1,
roff/troff/input.cpp-                         const errarg &arg2,
roff/troff/input.cpp-                         const errarg &arg3)
roff/troff/input.cpp-{
roff/troff/input.cpp-  if (program_name)
roff/troff/input.cpp-    fprintf(stderr, "%s:", program_name);
roff/troff/input.cpp-  fprintf(stderr, "%s:", filename);
roff/troff/input.cpp-  if (lineno > 0)


Dave <barx>
Group Member
Mon 24 Jul 2023 12:46:24 AM UTC, original submission:  

Subject: [groff] subroutine "debug_with_file_and_line" defined
differently in two source files

  The files are

libs/libgroff/error.cpp
 
  and

roff/troff/input.cpp

Command

cd src
grep -A10 -r -F 'debug_with_file_and_line' *

showed

include/error.h:void debug_with_file_and_line(const char , int, const char ,
include/error.h-                              const errarg & = empty_errarg,
include/error.h-                              const errarg & = empty_errarg,
include/error.h-                              const errarg & = empty_errarg);
include/error.h-
include/error.h-void fatal(const char *,
include/error.h-           const errarg & = empty_errarg,
include/error.h-           const errarg & = empty_errarg,
include/error.h-           const errarg & = empty_errarg);
include/error.h-
include/error.h-void error(const char *,
--
libs/libgroff/error.cpp:void debug_with_file_and_line(const char *filename,
libs/libgroff/error.cpp-                              int lineno,
libs/libgroff/error.cpp-                              const char *format,
libs/libgroff/error.cpp-                              const errarg &arg1,
libs/libgroff/error.cpp-                              const errarg &arg2,
libs/libgroff/error.cpp-                              const errarg &arg3)
libs/libgroff/error.cpp-{
libs/libgroff/error.cpp-  do_error_with_file_and_line(filename, 0 /* nullptr */, lineno,
libs/libgroff/error.cpp-                              DEBUG, format, arg1, arg2, arg3);
libs/libgroff/error.cpp-}
libs/libgroff/error.cpp-
--
roff/troff/input.cpp:void debug_with_file_and_line(const char *filename,
roff/troff/input.cpp-                         int lineno,
roff/troff/input.cpp-                         const char *format,
roff/troff/input.cpp-                         const errarg &arg1,
roff/troff/input.cpp-                         const errarg &arg2,
roff/troff/input.cpp-                         const errarg &arg3)
roff/troff/input.cpp-{
roff/troff/input.cpp-  if (program_name)
roff/troff/input.cpp-    fprintf(stderr, "%s:", program_name);
roff/troff/input.cpp-  fprintf(stderr, "%s:", filename);
roff/troff/input.cpp-  if (lineno > 0)

-.-

  The subroutine in "roff/trof/input.cpp" is not used there and should
be removed.

  A compilation of mine showed a linker error which disapered,
when this subroutine was commented out.

Bjarni Ingi Gislason <bjarniig>

 

(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 (Posted a comment)
  • -email is unavailable- added by barx (Posted a comment)
  • -email is unavailable- added by bjarniig (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-07-25 gbranden Item GroupLint Build/Installation
        StatusNeed Info Unreproducible
    2023-07-24 gbranden StatusNone Need Info
    2023-07-24 barx Item GroupBuild/Installation Lint

    Back to the top

    Powered by Savane 3.12.
    Corresponding source code