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

 
 

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

Submitted by:  J <now3d>
Submitted on:  Sat 14 Nov 2015 10:07:10 AM UTC  
 
Severity: 3 - NormalItem Group: Bug
Status: FixedPrivacy: Public
Assigned to: Paul D. Smith <psmith>Open/Closed: Closed
Component Version: NoneOperating System: None
Fixed Release: 4.2Triage Status: Small Effort

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission 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>
Project AdministratorIn charge of this item.
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 -jN 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 File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by psmith (Posted a comment)
  • -unavailable- added by phantal (Posted a comment)
  • -unavailable- added by now3d (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 10 Apr 2016 09:28:02 PM UTCpsmithItem 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.1-cleanup1