bugmake - Bugs: bug #41983, $(file) function crashes make

 
 

bug #41983: $(file) function crashes make

Submitted by:  Timothy N Murphy <tnmurphy>
Submitted on:  Thu 27 Mar 2014 10:35:52 PM UTC  
 
Severity: 3 - NormalItem Group: Bug
Status: FixedPrivacy: Public
Assigned to: Paul D. Smith <psmith>Open/Closed: Closed
Component Version: 4.0Operating System: Any
Fixed Release: 4.1Triage Status: Small Effort

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

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

 

Mon 07 Jul 2014 06:54:32 AM UTC, comment #5:

I pushed a fix for this as described below.

Paul D. Smith <psmith>
Project AdministratorIn charge of this item.
Tue 08 Apr 2014 10:03:01 PM UTC, comment #4:

Thanks Tim. Technically according to the docs it's not legal to call file without an argument; in other words, you should be running $(file >>4touch,) (note the comma) instead. However, to be clear this will add a newline to the file in all cases, which I suppose could be unwanted.

Obviously dumping core is not an appropriate response to a makefile error as well :-)

If we keep the currently documented requirement, then the right fix is to change the minimum number of arguments this function takes to 2, in which case your use will fail with: *** insufficient number of arguments (1) to function 'file'. Stop.

Alternatively we could accept a single argument and make that do something, and change the documentation. For $(file >x) it's clear that would create and truncate file "x" and "x" would be empty (rather than contain a newline). I guess for $(file >>x) it would create the file "x" if it didn't exist, and do nothing if it did exist. Does that seem useful?

Paul D. Smith <psmith>
Project AdministratorIn charge of this item.
Fri 28 Mar 2014 11:07:43 AM UTC, comment #3:

I have attached a patch which removes the segfault. The file is unchanged if one attempts to append "nothing" to it.

Timothy N Murphy <tnmurphy>
Thu 27 Mar 2014 10:41:49 PM UTC, comment #2:

The machine is running Fedora Core 20 Linux, x86_64.

Timothy N Murphy <tnmurphy>
Thu 27 Mar 2014 10:40:01 PM UTC, comment #1:

A makefile containing only:

$(file >>4touch)

Crashes make for me.

my git tree is uptodate at:

commit 8411528fdd21e978076365df2f49e2b934becb84

Valgrind reports this:

==7794== Invalid read of size 1
==7794== at 0x4A092F2: strlen (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==7794== by 0x40E374: func_file (function.c:2159)
==7794== by 0x410A88: handle_function (function.c:2422)
==7794== by 0x40AF8A: variable_expand_string (expand.c:256)
==7794== by 0x41C245: eval (read.c:1058)
==7794== by 0x41CEF4: eval_makefile (read.c:444)
==7794== by 0x41D1DD: read_all_makefiles (read.c:223)
==7794== by 0x406DD4: main (main.c:1878)
==7794== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==7794==
==7794==
==7794== Process terminating with default action of signal 11 (SIGSEGV)
==7794== Access not within mapped region at address 0x0
==7794== at 0x4A092F2: strlen (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==7794== by 0x40E374: func_file (function.c:2159)
==7794== by 0x410A88: handle_function (function.c:2422)
==7794== by 0x40AF8A: variable_expand_string (expand.c:256)
==7794== by 0x41C245: eval (read.c:1058)
==7794== by 0x41CEF4: eval_makefile (read.c:444)
==7794== by 0x41D1DD: read_all_makefiles (read.c:223)
==7794== by 0x406DD4: main (main.c:1878)
==7794== If you believe this happened as a result of a stack
==7794== overflow in your program's main thread (unlikely but
==7794== possible), you can try to increase the size of the
==7794== main thread stack using the --main-stacksize= flag.
==7794== The main thread stack size used in this run was 18446744073709551615.
==7794==

Timothy N Murphy <tnmurphy>
Thu 27 Mar 2014 10:35:52 PM UTC, original submission:
Timothy N Murphy <tnmurphy>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #31063:  file_segvfix.patch added by tnmurphy (1005B - text/x-patch - This patch causes make to not crash when writing an empty string to a file. The file contains no new bytes and the effect is similar to touch.)

 

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 tnmurphy (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 7 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 07 Jul 2014 06:54:32 AM UTCpsmithStatusNone=>Fixed
      Assigned toNone=>psmith
      Open/ClosedOpen=>Closed
      Operating SystemNone=>Any
      Fixed ReleaseNone=>4.1
      Triage StatusNone=>Small Effort
    Fri 28 Mar 2014 11:06:22 AM UTCtnmurphyAttached File-=>Added file_segvfix.patch, #31063

    Back to the top


    Powered by Savane 3.1-cleanup