Re: Defining and exporting and a variable undefined in a foreach loop cause a Segmentation fault with Make 4.2.1 on Debian bullseye/sid x64

2020-03-09 Thread Xavier Sanchez
I've built Make 4.3 and the attached Makefile works as intended.

The exact same Makefile produce the segfault on 4.2.1 on my x64 machine with
glibc 2.29-10.

What is your libc version ?

$ /usr/local/bin/make -v
GNU Make 4.3
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

$ /usr/local/bin/make  
build/a
build/b

$ make -v
GNU Make 4.2.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

$ make -d

[...]

Updating goal targets
Considering target file 'all'.
 File 'all' does not exist.
  Considering target file 'build/a'.
   File 'build/a' does not exist.
   Finished prerequisites of target file 'build/a'.
  Must remake target 'build/a'.
Segmentation fault

On 3/8/20 2:51 AM, Dmitry Goncharov wrote:
> On Thu, Mar 5, 2020 at 10:45 AM Xavier Sanchez  wrote:
>> Hi, I've got a segfault in __strlen_avx2 () at
>> ../sysdeps/x86_64/multiarch/strlen-avx2.S:65
>>
>> While defining a variable that has been undefined in a foreach loop using 
>> Make
>> 4.2.1 on my Bullseye/sid workstation.
> Does not reproduce for me with make-4.2.1 or make-4.3.90.
> Can you try make-4.3?
>
> regards, Dmitry

-- 
Xavier




Re: Defining and exporting and a variable undefined in a foreach loop cause a Segmentation fault with Make 4.2.1 on Debian bullseye/sid x64

2020-03-07 Thread Dmitry Goncharov via Bug reports and discussion for GNU make
On Thu, Mar 5, 2020 at 10:45 AM Xavier Sanchez  wrote:
>
> Hi, I've got a segfault in __strlen_avx2 () at
> ../sysdeps/x86_64/multiarch/strlen-avx2.S:65
>
> While defining a variable that has been undefined in a foreach loop using Make
> 4.2.1 on my Bullseye/sid workstation.

Does not reproduce for me with make-4.2.1 or make-4.3.90.
Can you try make-4.3?

regards, Dmitry



Defining and exporting and a variable undefined in a foreach loop cause a Segmentation fault with Make 4.2.1 on Debian bullseye/sid x64

2020-03-05 Thread Xavier Sanchez
Hi, I've got a segfault in __strlen_avx2 () at
../sysdeps/x86_64/multiarch/strlen-avx2.S:65

While defining a variable that has been undefined in a foreach loop using Make
4.2.1 on my Bullseye/sid workstation.

The code is a bit tricky. I've attached the Makefile and the backtrace.

# Bug in GNU Make 4.2.1
#
# defining a variable that has been undefined in a foreach loop produce a
# segfault on X64 machine.
#
# Disabling export avoid the sefault
export

# As same as disabling this define
DISCARD_ENV := templates from script format
define discard_env
$(foreach var,$(DISCARD_ENV),$(eval undefine $(var)))
endef

ARTIFACTS := build/a build/b

# In this situation: defining a variable that has been undefined
# in the foreach loop befaure causes the segfault:
templates := t1.tpl t2.tpl # <
format := qcow2

.PHONY: all
all: $(ARTIFACTS)

$(ARTIFACTS):
@echo $@

Starting program: /usr/bin/make 

Program received signal SIGSEGV, Segmentation fault.
__strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:65
65  ../sysdeps/x86_64/multiarch/strlen-avx2.S: No such file or directory.
#0  __strlen_avx2 () at 
../sysdeps/x86_64/multiarch/strlen-avx2.S:65
#1  0x5556392f in allocated_variable_append 
(v=0x555b75f0) at ../../expand.c:540
#2  recursively_expand_for_file (v=v@entry=0x555b75f0, 
file=file@entry=0x555b7880)
    at ../../expand.c:138
#3  0x5557d88d in target_environment 
(file=) at ../../variable.c:1090
#4  0x5556ceb1 in start_job_command 
(child=child@entry=0x555bb780) at ../../job.c:1364
#5  0x5556d812 in start_waiting_job 
(c=c@entry=0x555bb780) at ../../job.c:1605
#6  0x5556de28 in new_job (file=0x555b7880) 
at ../../job.c:1878
#7  0x55579d47 in remake_file 
(file=0x555b7880) at ../../remake.c:1234
#8  update_file_1 (depth=, 
file=0x555b7880) at ../../remake.c:835
#9  update_file (file=, depth=) at ../../remake.c:336
#10 0x5557a265 in check_dep 
(file=0x555b7880, depth=2, depth@entry=1, 
this_mtime=this_mtime@entry=1, 
must_make_ptr=must_make_ptr@entry=0x7fffbffc) at 
../../remake.c:1024
#11 0x55578fce in update_file_1 
(depth=, file=0x555b76c0) at 
../../remake.c:572
#12 update_file (file=file@entry=0x555b76c0, 
depth=) at ../../remake.c:336
#13 0x5557a6df in update_goal_chain 
(goaldeps=) at ../../remake.c:151
#14 0xef3f in main (argc=, 
argv=, envp=)
    at ../../main.c:2599
quit
# Bug in GNU Make 4.2.1
#
# defining a variable that has been undefined in a foreach loop produce a
# segfault on X64 machine.
#
# Disabling export avoid the sefault
export

# As same as disabling this part define
DISCARD_ENV := templates from script format
define discard_env
$(foreach var,$(DISCARD_ENV),$(eval undefine $(var)))
endef

ARTIFACTS := build/a build/b

# In this situation: defining a variable that has been undefined
# in the foreach loop befaure causes the segfault:
templates := t1.tpl t2.tpl # <
format := qcow2

.PHONY: all
all: $(ARTIFACTS)

$(ARTIFACTS):
@echo $@