bugmake - Bugs: bug #46443, $(warning message) line number...

 
 

bug #46443: $(warning message) line number incorrect if after TAB

Submitter:  J <now3d>
Submitted:  Sat 14 Nov 2015 10:07:10 AM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Fixed Privacy:  Public
Assigned to:  psmith Open/Closed:  Closed
Component Version:  None Operating System:  None
Fixed Release:  4.2 Triage Status:  Small Effort
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 11 Apr 2016 11:37:50 AM UTC, comment #7: 

Great work!

J <now3d>
Sun 10 Apr 2016 09:28:02 PM UTC, comment #6: 

I've implemented this change, mostly as described by Brian Vandenberg.  It will be available in the next release.

Paul D. Smith <psmith>
Group administrator
Sun 03 Jan 2016 02:02:37 PM UTC, comment #5: 

Many thanks for making the patch.

J <now3d>
Wed 02 Dec 2015 12:55:59 AM UTC, comment #4: 

I've just finished testing -n, -d, -p, --trace, and --warn-undefined-variables; they all seem to report correct line numbers.


Brian Vandenberg <phantal>
Wed 02 Dec 2015 12:41:55 AM UTC, comment #3: 

A minor correction to my last comment:

The change in job.c around line 2099 should be to add the line:

child->file->cmds->fileinfo.offset = child->command_line - 1;



With the changes I've outlined I see correct line numbers with this makefile:

.RECIPEPREFIX := >

TARGETS := 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

all: ${TARGETS}

> $(warning in $@, line 6)
> @true
> $(warning in $@, line 8)
> @true
> @true
> $(warning in $@, line 11)
> @true
> @true
> @true
> @-false


${TARGETS}:

> @-sleep $$(expr ${@} % 3)
> @-false
> @-false
> @-false
> $(warning in $@, line 22)
> $(warning in $@, line 23)
> $(warning in $@, line 24)
> @-false
> @-false
> @-false



I executed this with various combinations of -j*N* and didn't see the wrong line number reported:

~ gmake -f /tmp/makefile -j10 |& grep -P 'makefile:(\d+):.*, line (?!\1)|makefile:(?!15|18|19|20|21|25|26|27).*failed'


Brian Vandenberg <phantal>
Wed 02 Dec 2015 12:03:40 AM UTC, comment #2: 

I started to go down the path of changing job_next_command and new_job where allocated_variable_expand_for_file gets called, but quickly came to the conclusion that altering file->fileinfo.lineno wasn't the way to go at all.

The simplest approach I've found for fixing this is to change gmk_floc:

typedef struct
  {
    const char *filenm;
    unsigned long lineno;
+   unsigned long offset;
  } gmk_floc;

... then make the following modifications:

job.c, around line 1899:

      /* Finally, expand the line.  */
+     cmds->fileinfo.offset = i;
      lines[i] = allocated_variable_expand_for_file (cmds->command_lines[i], file );
    }

+ cmds->fileinfo.offset = 0;
  c->command_lines = lines;

job.c, around line 2099:

    }
+ child->file->cmds->fileinfo.offset = child->command_line;
  return 1;
}


Then at the very least change *some* of the following uses of (...)->lineno to add (...)->offset:

  • job.c, child_error()
  • job.c, new_job(), during tracing around line 2052
  • commands.c, print_commands()
  • file.c, line 273 in rehash_file()
  • function.c, line 1712
  • variable.c, line 1629


... and lastly (I think), in read.c and rule.c: change all initializations of "lineno" to also initialize "offset".

Brian Vandenberg <phantal>
Tue 17 Nov 2015 02:27:29 AM UTC, comment #1: 

There seems general agreement that this is a bug, however your interest in paying a bounty implies that you see it as a serious bug and it may not be that, given the existence of techniques such as http://www.cmcrossroads.com/article/tracing-rule-execution-gnu-make

Anonymous
Sat 14 Nov 2015 10:07:10 AM UTC, original submission:  

Hello


$ make -f makefile.mak
makefile.mak:2: One
makefile.mak:2: Two
makefile.mak:2: Three
Hello


makefile.mak (not sure if the TABs have been lost)
all:
    echo Hello
    $(warning One)
    $(warning Two)
    $(warning Three)


I can pay a bug bounty of $50 for a fix to the developer or FSF :)
Thank you
Jonny

J <now3d>

 

(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 psmith (Posted a comment)
  • -email is unavailable- added by phantal (Posted a comment)
  • -email is unavailable- added by now3d (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-04-10 psmith Item GroupNone Bug
        StatusNone Fixed
        Assigned toNone psmith
        Open/ClosedOpen Closed
        Fixed ReleaseNone 4.2
        Triage StatusNone Small Effort

    Back to the top

    Powered by Savane 3.13-f810.
    Corresponding source code