bugmake - Bugs: bug #20033, parallel (-j2) make with $(eval)...

 
 

bug #20033: parallel (-j2) make with $(eval) construct segfaults

Submitter:  None
Submitted:  Fri 01 Jun 2007 10:48:41 AM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Fixed Privacy:  Public
Assigned to:  psmith Open/Closed:  Closed
Component Version:  3.81 Operating System:  POSIX-Based
Fixed Release:  3.82 Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 14 Jun 2007 12:41:25 PM UTC, comment #5: 

Thanks, that works for me and mine.

Cheers,
  Rasmus

Rasmus Andersen <rasmus>
Thu 14 Jun 2007 02:27:57 AM UTC, comment #4: 

OK, I found it.  I'm still not 100% sure why it makes a difference between parallel and non-parallel jobs but I think I understand it.  The attached patch definitely seems to fix the problem.

(file #13043)

Paul D. Smith <psmith>
Group administrator
Thu 14 Jun 2007 01:29:56 AM UTC, comment #3: 

I can reproduce this as well and the fix seems simple enough.  The thing that's concerning me is WHY does it only happen with parallel makes?  There must be something non-obvious happening here because it doesn't seem to me like parallelism should change this behavior in the least.

I need to look at that before I'll feel comfortable just fixing the problem.

Paul D. Smith <psmith>
Group administrator
Fri 01 Jun 2007 08:43:52 PM UTC, comment #2: 

(I can reproduce a crash with that example.)

Martin Dorey <mdorey>
Fri 01 Jun 2007 07:52:33 PM UTC, comment #1: 

Hi, its me again. Find below a trivial makefile to recreate this. run 'make setup && make -j2' to get a segfault.

Cheers,
  Rasmus

A := $(wildcard *.a)

.PHONY: all
all: $(A:.a=.b)

.PHONY: clean
clean:
        rm -f $(A)

.PHONY: setup
setup:
        @touch 1.a 2.a 3.a 4.a 5.a 6.a

define d1
@echo lala $(1)
@sleep 1
endef

define d2
@echo tyty $(1)
@sleep 1
endef

%.b : %.a
        $(eval CHECKSUM := $(word 1,$(shell cat $^ | sha1sum))) $(if $(wildcard $(CACHEDIR)/$(CHECKSUM)),\
                $(call d1,$(CHECKSUM)),\
                $(call d2,$(CHECKSUM)))

Anonymous
Fri 01 Jun 2007 10:48:41 AM UTC, original submission:  

Hello,

At work I have a (proprietary, sorry) makefile where I use an $(eval) construct. It goes like

foo: bar
        $(eval CHECKSUM := $(word 1,$(shell cat $^ | sha1sum))) $(if $(wildcard $(CACHEDIR)/$(CHECKSUM)), $(call do-copy,$(CHECKSUM)), $(call do-dct4-selection,$(CHECKSUM)))

This runs nicely with a plain make but if I try make -j2 I get a segfault. I have captured this in gdb, output below


(gdb) bt
#0  eval_buffer (
    buffer=0x819abb8 "CHECKSUM := ac2773ef9cb98feab91b3ddfeedc20019d1516c3")
    at read.c:430
#1  0x08050012 in func_eval (o=0x819aae9 "[\230[", argv=0x0,
    funcname=0x8062e38 "eval") at function.c:1369
#2  0x080506a8 in expand_builtin_function (o=0x819aae9 "[\230[",
    argc=135900088, argv=0xfeffa8b0, entry_p=0xffffffca) at function.c:2115
#3  0x08050819 in handle_function (op=0xfeffa944, stringp=0x818ea38)
    at function.c:2213
#4  0x0804c630 in variable_expand_string (line=0x0,
    string=0x818ea00 "\t$(eval CHECKSUM := $(word 1,$(shell cat $^ | sha1sum))) $(if $(wildcard $(CACHEDIR)/$(CHECKSUM)), $(call do-copy,$(CHECKSUM)), $(call do-dct4-selection,$(CHECKSUM)))", length=-1) at expand.c:253
#5  0x0804c9a6 in variable_expand (
    line=0x818ea00 "\t$(eval CHECKSUM := $(word 1,$(shell cat $^ | sha1sum))) $(if $(wildcard $(CACHEDIR)/$(CHECKSUM)), $(call do-copy,$(CHECKSUM)), $(call do-dct4-selection,$(CHECKSUM)))") at expand.c:418
#6  0x0804ca40 in variable_expand_for_file (
    line=0xffffffca <Address 0xffffffca out of bounds>, file=0x819abb8)
    at expand.c:463
#7  0x0804cc15 in allocated_variable_expand_for_file (
    line=0x818ea00 "\t$(eval CHECKSUM := $(word 1,$(shell cat $^ | sha1sum))) $(if $(wildcard $(CACHEDIR)/$(CHECKSUM)), $(call do-copy,$(CHECKSUM)), $(call do-dct4-selection,$(CHECKSUM)))", file=0x80725b8) at expand.c:548
#8  0x08053319 in new_job (file=0x80725b8) at job.c:1600
#9  0x0805c28a in update_file_1 (file=0x80725b8, depth=0) at remake.c:761
#10 0x0805b984 in update_file (file=0x80725b8, depth=0) at remake.c:307
#11 0x0805b63f in update_goal_chain (goals=0x80ba8d8) at remake.c:154
#12 0x080551a2 in main (argc=7, argv=0xfeffc454, envp=0xfeffc474)
    at main.c:2198
(gdb) print reading_file
$1 = (const struct floc *) 0x0

line 430 at read.c:

  ebuf.floc = *reading_file;

So we try to dereference a NULL pointer here. As stated this is make 3.81.

I hope this is of help, otherwise I'll try to provide more information.

Cheers,
  Rasmus

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #13043:  20033.diff added by psmith (2KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rasmus (Posted a comment)
  • -email is unavailable- added by psmith (Posted a comment)
  • -email is unavailable- added by mdorey (Posted a comment)
  •  

    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
    2007-06-14 psmith Attached File- Added 20033.diff, #13043
        StatusNone Fixed
        Assigned toNone psmith
        Open/ClosedOpen Closed
        Fixed ReleaseNone 4.0
    2007-06-02 rasmus Carbon-Copy- Added rasmus

    Back to the top

    Powered by Savane 3.14-f13d.
    Corresponding source code