SECONDEXPANSION segmentation fault with make 3.82.90

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

SECONDEXPANSION segmentation fault with make 3.82.90

Martin d'Anjou-5
Hello,

I have found a segmentation fault executing make. This makefile makes
little sense, but it reproduces the segfault:

.SECONDEXPANSION:
sim_base_rgg := just_a_name
sim_base_src := a
sim_base_f := a a a

sim_%.f: $${sim_$$*_f}
        echo $@

sim_%.src: $${sim_$$*_src}
        echo $@

sim_%: \
        $$(if $$(sim_$$*_src),sim_%.src) \
  $$(if $$(sim_$$*_f),sim_%.f) \
  $$(if $$(sim_$$*_rgg),$$(sim_$$*_rgg).s)
        echo $@

To reproduce:
$ touch a
$ make sim_base
*** glibc detected *** /home/martin/Downloads/make/make: free(): invalid
pointer: 0x000000000092a540 ***

The backtrace in gdb looks like this:
#0  0x00007ffff7645425 in __GI_raise (sig=<optimized out>) at
../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00007ffff7648b8b in __GI_abort () at abort.c:91
#2  0x00007ffff768339e in __libc_message (do_abort=2, fmt=0x7ffff778d008
"*** glibc detected *** %s: %s: 0x%s ***\n")
    at ../sysdeps/unix/sysv/linux/libc_fatal.c:201
#3  0x00007ffff768db96 in malloc_printerr (action=3, str=0x7ffff7789913
"free(): invalid pointer", ptr=<optimized out>)
    at malloc.c:5018
#4  0x0000000000411457 in pattern_search (file=<optimized out>,
archive=<optimized out>, depth=1, recursions=0)
    at implicit.c:974
#5  0x000000000041229f in try_implicit_rule (file=0x656af0, depth=1) at
implicit.c:45
#6  0x000000000041f98b in update_file_1 (depth=<optimized out>,
file=0x656af0) at remake.c:491
#7  update_file (file=0x656af0, depth=0) at remake.c:315
#8  0x000000000041ff77 in update_goal_chain (goals=0x6624b0) at remake.c:155
#9  0x0000000000407334 in main (argc=4, argv=0x7fffffffea68,
envp=<optimized out>) at main.c:2516



This segfault was reproduced on RHEL 6.3 and on an up-to-date linux mint 13
host.

Is this a bug? If so, can someone post a patch please?

Thanks,
Martin
_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: SECONDEXPANSION segmentation fault with make 3.82.90

Paul Smith-20
Every segmentation fault is by definition a bug...

Thanks for the repro case!  I'll try to look into this when I get home
tonight.


On Tue, 2013-07-09 at 14:20 -0400, Martin d'Anjou wrote:

> Hello,
>
> I have found a segmentation fault executing make. This makefile makes
> little sense, but it reproduces the segfault:
>
> .SECONDEXPANSION:
> sim_base_rgg := just_a_name
> sim_base_src := a
> sim_base_f := a a a
>
> sim_%.f: $${sim_$$*_f}
>         echo $@
>
> sim_%.src: $${sim_$$*_src}
>         echo $@
>
> sim_%: \
>         $$(if $$(sim_$$*_src),sim_%.src) \
>   $$(if $$(sim_$$*_f),sim_%.f) \
>   $$(if $$(sim_$$*_rgg),$$(sim_$$*_rgg).s)
>         echo $@
>
> To reproduce:
> $ touch a
> $ make sim_base
> *** glibc detected *** /home/martin/Downloads/make/make: free(): invalid
> pointer: 0x000000000092a540 ***
>
> The backtrace in gdb looks like this:
> #0  0x00007ffff7645425 in __GI_raise (sig=<optimized out>) at
> ../nptl/sysdeps/unix/sysv/linux/raise.c:64
> #1  0x00007ffff7648b8b in __GI_abort () at abort.c:91
> #2  0x00007ffff768339e in __libc_message (do_abort=2, fmt=0x7ffff778d008
> "*** glibc detected *** %s: %s: 0x%s ***\n")
>     at ../sysdeps/unix/sysv/linux/libc_fatal.c:201
> #3  0x00007ffff768db96 in malloc_printerr (action=3, str=0x7ffff7789913
> "free(): invalid pointer", ptr=<optimized out>)
>     at malloc.c:5018
> #4  0x0000000000411457 in pattern_search (file=<optimized out>,
> archive=<optimized out>, depth=1, recursions=0)
>     at implicit.c:974
> #5  0x000000000041229f in try_implicit_rule (file=0x656af0, depth=1) at
> implicit.c:45
> #6  0x000000000041f98b in update_file_1 (depth=<optimized out>,
> file=0x656af0) at remake.c:491
> #7  update_file (file=0x656af0, depth=0) at remake.c:315
> #8  0x000000000041ff77 in update_goal_chain (goals=0x6624b0) at remake.c:155
> #9  0x0000000000407334 in main (argc=4, argv=0x7fffffffea68,
> envp=<optimized out>) at main.c:2516


_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: SECONDEXPANSION segmentation fault with make 3.82.90

Paul Smith-20
In reply to this post by Martin d'Anjou-5
On Tue, 2013-07-09 at 14:20 -0400, Martin d'Anjou wrote:
> I have found a segmentation fault executing make. This makefile makes
> little sense, but it reproduces the segfault:

Thanks for the report.  I've pushed a fix for this fault.  You can use
the attached patch to try the fix yourself.

Cheers!


_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make

implicit.patch (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: SECONDEXPANSION segmentation fault with make 3.82.90

Martin d'Anjou-5
Thanks a lot. It works.


On Tue, Jul 9, 2013 at 7:18 PM, Paul Smith <[hidden email]> wrote:

> On Tue, 2013-07-09 at 14:20 -0400, Martin d'Anjou wrote:
> > I have found a segmentation fault executing make. This makefile makes
> > little sense, but it reproduces the segfault:
>
> Thanks for the report.  I've pushed a fix for this fault.  You can use
> the attached patch to try the fix yourself.
>
> Cheers!
>
>
_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make