bugmake - Bugs: bug #24622, $$(eval) creating new targets...

 
 

bug #24622: $$(eval) creating new targets causes segmentation fault

Submitter:  Lars S. Jessen <ljessen>
Submitted:  Tue 21 Oct 2008 06:15:25 PM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Fixed Privacy:  Public
Assigned to:  psmith Open/Closed:  Closed
Component Version:  3.81 Operating System:  None
Fixed Release:  3.82 Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 07 Jun 2009 06:17:38 PM UTC, comment #5: 

Oops.  I had a change I was testing that fixed this bug but took it out.  Added it back now and this is really fixed (reports an error but does not segfault).

Paul D. Smith <psmith>
Group administrator
Thu 04 Jun 2009 12:52:43 PM UTC, comment #4: 

No, this bug is not a duplicate of bug #24588, the fix for bug #24588 does not solve this problem. Latest make from cvs still segfaults with the example in the original submission.

Lars S. Jessen <ljessen>
Mon 01 Jun 2009 11:14:45 AM UTC, comment #3: 

This is a duplicate of bug #24588

Paul D. Smith <psmith>
Group administrator
Tue 21 Oct 2008 07:35:33 PM UTC, comment #2: 

IMO, adding new targets during the second expansion is conceptually wrong. Granted make shouldn't segfault, in this case we should just report an error, the same kind that make emits when seeing something like this:

proj1.exe : proj1.o proj1.o : proj1.c

Boris Kolpackov <bosk>
Group Member
Tue 21 Oct 2008 07:23:08 PM UTC, comment #1: 

The crash happens when update_file() gets called with the "proj1.c" target. It seems that expand_deps() was newer called on the "proj1.c" target

The problem seems to lie inside snap_deps() in the loop that expands target dependencies, using expand_deps(). The problem is that snap_deps() only iterates through targets known in advance, and since the "proj1.c" target gets born when expand_deps() on "proj1.exe" is called, this target is newer expanded.

A possible solution to this problem is to continue iterating through all targets until we are sure that all targets have had their dependencies expanded. I've attached a patch that fixes the problem using this approach.


(file #16718)

Lars S. Jessen <ljessen>
Tue 21 Oct 2008 06:15:25 PM UTC, original submission:  

$$(eval) with SECONDEXPANSION enabled causes make to crash with a segmentation fault when the expanded variable creates new targets.

The following makefile reproduces the crash:

$ cat Makefile
.SECONDEXPANSION:

proj1.exe : proj1.o $$(eval $$(test))

define test
proj1.o : proj1.c
proj1.c: proj1.h
endef

$ make
Segmentation fault

Lars S. Jessen <ljessen>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #16718:  fix24622.patch added by ljessen (4KiB - text/x-diff - Patch for file.c rev 1.90 and filedef.h rev 2.30)

 

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 bosk (Posted a comment)
  • -email is unavailable- added by ljessen (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
    2010-07-28 psmith Fixed Release4.0 3.82
    2009-06-07 psmith StatusDuplicate Fixed
        Assigned toNone psmith
        Fixed ReleaseNone 4.0
    2009-06-01 psmith StatusNone Duplicate
        Open/ClosedOpen Closed
    2008-10-21 ljessen Attached File- Added fix24622.patch, #16718

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code