segfault (memory leak?) in GNU Make 3.82.90 (CVS HEAD)

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

segfault (memory leak?) in GNU Make 3.82.90 (CVS HEAD)

Martin d'Anjou-5
Hi,

I am getting a segmentation fault with GNU Make 3.82.90 (CVS HEAD as of
earlier today). To obtain more information, I have run it in valgrind.
The report is quite long, here is an excerpt:

...
==6816== Invalid write of size 8
==6816==    at 0x40B428: pattern_search (implicit.c:688)
==6816==    by 0x40BA3E: pattern_search (implicit.c:755)
==6816==    by 0x40BA3E: pattern_search (implicit.c:755)
==6816==    by 0x40C1A0: try_implicit_rule (implicit.c:45)
==6816==    by 0x418FB5: update_file (remake.c:491)
==6816==    by 0x419C15: update_goal_chain (remake.c:155)
==6816==    by 0x411C25: main (main.c:2337)
==6816==  Address 0x5405530 is 0 bytes after a block of size 64 alloc'd
==6816==    at 0x4A0776F: malloc (vg_replace_malloc.c:263)
==6816==    by 0x4125A8: xmalloc (misc.c:374)
==6816==    by 0x40ABB2: pattern_search (implicit.c:221)
==6816==    by 0x40BA3E: pattern_search (implicit.c:755)
==6816==    by 0x40BA3E: pattern_search (implicit.c:755)
==6816==    by 0x40C1A0: try_implicit_rule (implicit.c:45)
==6816==    by 0x418FB5: update_file (remake.c:491)
==6816==    by 0x419C15: update_goal_chain (remake.c:155)
==6816==    by 0x411C25: main (main.c:2337)
...
==6816== Process terminating with default action of signal 11 (SIGSEGV)
==6816==  Access not within mapped region at address 0x0
==6816==    at 0x4A08862: strlen (mc_replace_strmem.c:390)
==6816==    by 0x41B428: strcache_add (strcache.c:191)
==6816==    by 0x40BC08: pattern_search (implicit.c:883)
==6816==    by 0x40BA3E: pattern_search (implicit.c:755)
==6816==    by 0x40BA3E: pattern_search (implicit.c:755)
==6816==    by 0x40C1A0: try_implicit_rule (implicit.c:45)
==6816==    by 0x418FB5: update_file (remake.c:491)
==6816==    by 0x419C15: update_goal_chain (remake.c:155)
==6816==    by 0x411C25: main (main.c:2337)
...
==6816== LEAK SUMMARY:
==6816==    definitely lost: 85 bytes in 4 blocks
==6816==    indirectly lost: 0 bytes in 0 blocks
==6816==      possibly lost: 3 bytes in 1 blocks
==6816==    still reachable: 672,520 bytes in 3,700 blocks
==6816==         suppressed: 0 bytes in 0 blocks
...

I don't know how to narrow my makefile down to find the culprit.

Thanks in advance,
Martin

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

re: segfault (memory leak?) in GNU Make 3.82.90 (CVS HEAD)

Martin d'Anjou-6
Hi,

I worked at narrowing down the segfault problem I am getting with both
GNU Make 3.82 and 3.82.90. This is the smallest makefile I came up with:

.SECONDEXPANSION:
gen_default_Test_f := \
   file1 \
   file2
gen_default_Test_bar := bar_foo

gen_%.f: $${gen_$$*_f}
   @echo "f $@"

gen_%: \
   $$(if $$(gen_$$*_f),gen_%.f) \
   $$(if $$(gen_$$*_bar),$$(gen_$$*_bar).ext)
   @echo "$@"


The backtrace in gdb with version 3.82 is:

Program received signal SIGABRT, Aborted.
0xffffe410 in __kernel_vsyscall ()
(gdb) bt
#0  0xffffe410 in __kernel_vsyscall ()
#1  0x00949df0 in raise () from /lib/libc.so.6
#2  0x0094b701 in abort () from /lib/libc.so.6
#3  0x0098228b in __libc_message () from /lib/libc.so.6
#4  0x0098a5a5 in _int_free () from /lib/libc.so.6
#5  0x0098a9e9 in free () from /lib/libc.so.6
#6  0x08052a36 in pattern_search (file=0x807c518, archive=10891252,
depth=1, recursions=0) at implicit.c:976
#7  0x08053f63 in try_implicit_rule (file=0x807c518, depth=1) at
implicit.c:47
#8  0x0806117b in update_file (file=0x807c518, depth=0) at remake.c:493
#9  0x08061b54 in update_goal_chain (goals=0x807e548) at remake.c:157
#10 0x0805979c in main (argc=8, argv=0xffffd164, envp=0xffffd188) at
main.c:2282

I compiled GNU Make with both 32-bit and 64-bit compile on RedHat 5.5
and they both have this problem. In 3.81, there is no segfault.

Could anyone shed light on this? I am a big fan of conditional
prerequisites done with SECONDEXPANSION. I hope they will still work.

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: segfault (memory leak?) in GNU Make 3.82.90 (CVS HEAD)

Martin d'Anjou-5
In reply to this post by Martin d'Anjou-5
Hi,

Sorry for the double post, I sent this from the wrong account... here it is again.

I worked at narrowing down the segfault problem I am getting with both
GNU Make 3.82 and 3.82.90. This is the smallest makefile I came up with:

.SECONDEXPANSION:
gen_default_Test_f := \
    file1 \
    file2
gen_default_Test_bar := bar_foo

gen_%.f: $${gen_$$*_f}
    @echo "f $@"

gen_%: \
    $$(if $$(gen_$$*_f),gen_%.f) \
    $$(if $$(gen_$$*_bar),$$(gen_$$*_bar).ext)
    @echo "$@"


The backtrace in gdb with version 3.82 is:

Program received signal SIGABRT, Aborted.
0xffffe410 in __kernel_vsyscall ()
(gdb) bt
#0  0xffffe410 in __kernel_vsyscall ()
#1  0x00949df0 in raise () from /lib/libc.so.6
#2  0x0094b701 in abort () from /lib/libc.so.6
#3  0x0098228b in __libc_message () from /lib/libc.so.6
#4  0x0098a5a5 in _int_free () from /lib/libc.so.6
#5  0x0098a9e9 in free () from /lib/libc.so.6
#6  0x08052a36 in pattern_search (file=0x807c518, archive=10891252,
depth=1, recursions=0) at implicit.c:976
#7  0x08053f63 in try_implicit_rule (file=0x807c518, depth=1) at
implicit.c:47
#8  0x0806117b in update_file (file=0x807c518, depth=0) at remake.c:493
#9  0x08061b54 in update_goal_chain (goals=0x807e548) at remake.c:157
#10 0x0805979c in main (argc=8, argv=0xffffd164, envp=0xffffd188) at
main.c:2282

I compiled GNU Make with both 32-bit and 64-bit compile on RedHat 5.5
and they both have this problem. In 3.81, there is no segfault.

Could anyone shed light on this? I am a big fan of conditional
prerequisites done with SECONDEXPANSION. I hope they will still work.

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: segfault (memory leak?) in GNU Make 3.82.90 (CVS HEAD)

Martin d'Anjou-5
Hi,

Rereading this post, I see that I did not show what command lead to the
segfault problem. Here it is again. Should I file a bug?

.SECONDEXPANSION:
gen_default_Test_f := \
    file1 \
    file2
gen_default_Test_bar := bar_foo

gen_%.f: $${gen_$$*_f}
    @echo "f $@"

gen_%: \
    $$(if $$(gen_$$*_f),gen_%.f) \
    $$(if $$(gen_$$*_bar),$$(gen_$$*_bar).ext)
    @echo "$@"

$ touch file1
$ touch file2
$ make gen_default_Test

When I use GNU Make 3.81, this works as expected, when I use GNU Make 3.82, it segfaults.

Regards,
Martin



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

Re: segfault (memory leak?) in GNU Make 3.82.90 (CVS HEAD)

Paul Smith-20
On Wed, 2012-04-18 at 20:52 -0400, Martin d'Anjou wrote:

> .SECONDEXPANSION:
> gen_default_Test_f := \
>     file1 \
>     file2
> gen_default_Test_bar := bar_foo
>
> gen_%.f: $${gen_$$*_f}
>     @echo "f $@"
>
> gen_%: \
>     $$(if $$(gen_$$*_f),gen_%.f) \
>     $$(if $$(gen_$$*_bar),$$(gen_$$*_bar).ext)
>     @echo "$@"
>
> $ touch file1
> $ touch file2
> $ make gen_default_Test

I've tried the above and in all versions (3.81, 3.82, latest CVS) I get
the same result:

  make: *** No rule to make target 'gen_default_Test'.  Stop.

Are you sure there's not more needed here?

--
-------------------------------------------------------------------------------
 Paul D. Smith <[hidden email]>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist


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

Re: segfault (memory leak?) in GNU Make 3.82.90 (CVS HEAD)

Martin d'Anjou-5

> I've tried the above and in all versions (3.81, 3.82, latest CVS) I get
> the same result:
>
>    make: *** No rule to make target 'gen_default_Test'.  Stop.
>
> Are you sure there's not more needed here?
>

I just tried again too. On RedHat Entreprise 5, it does not work, but on
a more recent distro (Mint 11), it works.

Must be a bug in one of the older libraries. Thanks for checking.

Martin


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