bugmake - Bugs: bug #27143, Crash in a pair of mutually...

 
 

bug #27143: Crash in a pair of mutually recursive macros

Submitter:  Timothy N Murphy <tnmurphy>
Submitted:  Thu 30 Jul 2009 04:42:11 PM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Fixed Privacy:  Public
Assigned to:  psmith Open/Closed:  Closed
Component Version:  3.81 Operating System:  Any
Fixed Release:  3.82 Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 02 Aug 2009 12:10:33 AM UTC, comment #1: 

Another alloca() issue.  Really, it would be much nicer if we didn't need this alloc at all; we need it because not all functions in make that deal with strings accept a length or end pointer argument.

Changed expand_argument() to use malloc() if the size is >1000 bytes.  Now the test run works fine on my 32bit Ubuntu 8.04, whereas before it dumped core.

Paul D. Smith <psmith>
Group administrator
Thu 30 Jul 2009 04:42:11 PM UTC, original submission:  

This crash happens on win32 with mingw make 3.81 for us and on Redhat 4 (32) with custom built gnu make 3.81 (32-bit), also CentOS 5.3 (64) using gnu make 3.81 (32).

It appears to succeed on Fedora 11 with make 3.81 (64) but fail with a custom built 32-bit make (linked to compat-glibc).

Sorry for the confusion there. 

My example is a bit big at the moment.

I used valgrind to see what was happening:



==24453==
==24453== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 14 from 1)
==24453== malloc/free: in use at exit: 44,167 bytes in 1,216 blocks.
==24453== malloc/free: 2,785 allocs, 1,569 frees, 93,301 bytes allocated.
==24453== For counts of detected errors, rerun with: -v
==24453== searching for pointers to 1,216 not-freed blocks.
==24453== checked 147,452 bytes.
==24453==
==24453== LEAK SUMMARY:
==24453==    definitely lost: 0 bytes in 0 blocks.
==24453==      possibly lost: 0 bytes in 0 blocks.
==24453==    still reachable: 44,167 bytes in 1,216 blocks.
==24453==         suppressed: 0 bytes in 0 blocks.
==24453== Rerun with --leak-check=full to see details of leaked memory.
[tmurphy@head t]cd ~/tmp/
[tmurphy@head tmp]valgrind make -f t.mk
==24462== Memcheck, a memory error detector.
==24462== Copyright (C) 2002-2008, and GNU GPL'd, by Julian Seward et al.
==24462== Using LibVEX rev 1884, a library for dynamic binary translation.
==24462== Copyright (C) 2004-2008, and GNU GPL'd, by OpenWorks LLP.
==24462== Using valgrind-3.4.1, a dynamic binary instrumentation framework.
==24462== Copyright (C) 2000-2008, and GNU GPL'd, by Julian Seward et al.
==24462== For more details, rerun with: -v
==24462==
==24462== Warning: client switching stacks?  SP change: 0xbefbba80 --> 0xbd5fbc50
==24462==          to suppress, use: --max-stackframe=27000368 or greater
==24462==
==24462== Process terminating with default action of signal 11 (SIGSEGV)
==24462==  Access not within mapped region at address 0xBD5FBC48
==24462==    at 0x804D4FC: expand_argument (expand.c:439)
==24462==  If you believe this happened as a result of a stack overflow in your
==24462==  program's main thread (unlikely but possible), you can try to increase
==24462==  the size of the main thread stack using the --main-stacksize= flag.
==24462==  The main thread stack size used in this run was -1.
==24462==
==24462== Process terminating with default action of signal 11 (SIGSEGV)
==24462==  Access not within mapped region at address 0xBD5FBC44
==24462==    at 0x40005A3: _vgnU_freeres (vg_preloaded.c:56)
==24462==  If you believe this happened as a result of a stack overflow in your
==24462==  program's main thread (unlikely but possible), you can try to increase
==24462==  the size of the main thread stack using the --main-stacksize= flag.
==24462==  The main thread stack size used in this run was -1.
==24462==
==24462== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 14 from 1)
==24462== malloc/free: in use at exit: 137,065,676 bytes in 699 blocks.
==24462== malloc/free: 2,031,760 allocs, 2,031,061 frees, 2,078,692,395 bytes allocated.
==24462== For counts of detected errors, rerun with: -v
==24462== searching for pointers to 699 not-freed blocks.
==24462== checked 137,170,860 bytes.
==24462==
==24462== LEAK SUMMARY:
==24462==    definitely lost: 0 bytes in 0 blocks.
==24462==      possibly lost: 0 bytes in 0 blocks.
==24462==    still reachable: 137,065,676 bytes in 699 blocks.
==24462==         suppressed: 0 bytes in 0 blocks.
==24462== Rerun with --leak-check=full to see details of leaked memory.


The makefile contains:

# Crash in a recursing macro


# AllSuffixSubst
## Converting a list of source files to a list of object files without altering
## their relative order. Also deals with multiple file types mapping to the same
## object type e.g. .CPP and .cpp and .c++ all map to .o

# $1 - the list of suffixes to replace
# $2 - the suffix to replace them with
# $3 - the list of strings to perform the replacement on
define allsuffixsubst_internal
    $(if $1,$$(patsubst %$(firstword $1),%$2,$(call allsuffixsubst_internal,$(wordlist 2,$(words $1),$1),$2,$3)),$3)
    endef
    define allsuffixsubst
        $(eval allsuffixsubst_RESULT:=$(call allsuffixsubst_internal,$1,$2,$3))$(allsuffixsubst_RESULT)
        endef

        x10:=1 2 3 4 5 6 7 8 9 0
        x100:=$(foreach i,$(x10),$(x10))
        x10000:=$(foreach i,$(x100),$(x100))
        x1000000:=$(foreach i,$(x10000),$(x100))

        somefiles:=$(foreach f,$(x1000000),fred.cia fred.cpp fred.c++)
        objects:=$(call allsuffixsubst,.Cia .CiA .cIA. .CpP .cPp .CC .C++ .cia .cpp .c++ .cc .CPP .CIA .Cpp,.o,$(somef
iles))

Timothy N Murphy <tnmurphy>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by psmith (Posted a comment)
  • -email is unavailable- added by tnmurphy (Submitted the item)
  •  

    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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-07-28 psmith Fixed Release4.0 3.82
    2009-08-02 psmith StatusNone Fixed
        Assigned toNone psmith
        Open/ClosedOpen Closed
        Fixed ReleaseNone 4.0

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code