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

 
 

bug #41983: $(file) function crashes make

Submitter:  Timothy N Murphy <tnmurphy>
Submitted:  Thu 27 Mar 2014 10:35:52 PM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Fixed Privacy:  Public
Assigned to:  psmith Open/Closed:  Closed
Component Version:  4.0 Operating System:  Any
Fixed Release:  4.1 Triage Status:  Small Effort
* Mandatory Fields

Add a New Comment Rich Markup
   

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

I pushed a fix for this as described below.

Paul D. Smith <psmith>
Group administrator
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>
Group administrator
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 Files:
   
   
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
  • -email is unavailable- added by psmith (Posted a comment)
  • -email is unavailable- added by tnmurphy (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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-07-07 psmith StatusNone Fixed
        Assigned toNone psmith
        Open/ClosedOpen Closed
        Operating SystemNone Any
        Fixed ReleaseNone 4.1
        Triage StatusNone Small Effort
    2014-03-28 tnmurphy Attached File- Added file_segvfix.patch, #31063

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code