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

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

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

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 $@


gdb.txt (3K) Download Attachment
Makefile (812 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

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

Gnu - Make - Bugs mailing list
On Thu, Mar 5, 2020 at 10:45 AM Xavier Sanchez <[hidden email]> 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

Reply | Threaded
Open this post in threaded view
|

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

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 <http://gnu.org/licenses/gpl.html>
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 <http://gnu.org/licenses/gpl.html>
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 <[hidden email]> 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