remake (and make) memory free() error

Bug #252415 reported by Philip Ashmore on 2008-07-27
Affects Status Importance Assigned to Milestone
remake (Ubuntu)

Bug Description

Binary package hint: remake

lsb_release -d => Ubuntu 8.04.1
remake -v => GNU Make + Debugger 3.80+dbg-0.62
make : GNU Make 3.81

This is a strange one.

The problem surfaces in make and remake depending on the project location, comments, etc., so I'm guessing that memory is being stepped on somewhere.

Sometimes it's make that crashes, sometimes remake, sometimes both.

At least it's reproducible so hopefully this little test-project will help you track it down.

"make" builds the dummy program and "make clean" cleans up - nice and simple for testing.

If you unpack the contents of the archive I will attach below to /opt/dev/bugs/make then
    $ cd /opt/dev/bugs/make/arena
    $ remake

you get

/opt/dev/bugs/make/arena$ remake
remake[1]: Entering directory `/opt/dev/bugs/make/arena/src' ARENA_ROOT_DIR = /opt/dev/bugs/make/arena ARENA_SRC_DIR = /opt/dev/bugs/make/arena/src
src.mak:14: ARENA_SUB_DIRS=macro_test = [$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c]
CXX = [g++]
CXXFLAGS = [-fPIC -D_FILE_OFFSET_BITS=64 -DLINUX -D_REENTRANT -O0 -ggdb -pipe -I /opt/dev/bugs/make/arena/src/include -I /opt/dev/bugs/make/arena/gen/i486-linux-gnu/include -I /opt/dev/bugs/make/arena/gen/noarch/include -I /opt/dev]
LDFLAGS = [-pie]
CC_VER = [i486-linux-gnu]
ARENA_GEN_DIR = [/opt/dev/bugs/make/arena/gen]
src.mak:16: <mkdir> /opt/dev/bugs/make/arena/gen
src.mak:16: <mkdir> /opt/dev/bugs/make/arena/gen/i486-linux-gnu
src.mak:16: <mkdir> /opt/dev/bugs/make/arena/gen/i486-linux-gnu/include
src.mak:16: <mkdir> /opt/dev/bugs/make/arena/gen/i486-linux-gnu/obj
src.mak:16: <mkdir> /opt/dev/bugs/make/arena/gen/i486-linux-gnu/bin
src.mak:16: <mkdir> /opt/dev/bugs/make/arena/gen/i486-linux-gnu/lib
src.mak:16: <mkdir> /opt/dev/bugs/make/arena/gen/noarch
src.mak:16: <mkdir> /opt/dev/bugs/make/arena/gen/noarch/include
remake all -C macro_test -I /opt/dev/bugs/make/arena/src -f /opt/dev/bugs/make/arena/src/ -f macro_test.mak -f /opt/dev/bugs/make/arena/src/
remake[2]: Entering directory `/opt/dev/bugs/make/arena/src/macro_test'
/opt/dev/bugs/make/arena/src/ <mkdir> /opt/dev/bugs/make/arena/gen/i486-linux-gnu/obj/macro_test
Pre-recurse [simple] complete
remake --warn-undefined-variables all -C simple -I /opt/dev/bugs/make/arena/src -f /opt/dev/bugs/make/arena/src/macro_test/ -f simple.mak -f /opt/dev/bugs/make/arena/src/macro_test/
remake[3]: Entering directory `/opt/dev/bugs/make/arena/src/macro_test/simple'
/opt/dev/bugs/make/arena/src/ <mkdir> /opt/dev/bugs/make/arena/gen/i486-linux-gnu/obj/macro_test/simple
Need to make simple
g++ -fPIC -D_FILE_OFFSET_BITS=64 -DLINUX -D_REENTRANT -O0 -ggdb -pipe -I /opt/dev/bugs/make/arena/src/include -I /opt/dev/bugs/make/arena/gen/i486-linux-gnu/include -I /opt/dev/bugs/make/arena/gen/noarch/include -I /opt/dev -DCPPU_ENV=gcc4 -c simple.cpp -o /opt/dev/bugs/make/arena/gen/i486-linux-gnu/obj/macro_test/simple/simple.o
Making simple from /opt/dev/bugs/make/arena/gen/i486-linux-gnu/obj/macro_test/simple/simple.o
g++ -pie -o /opt/dev/bugs/make/arena/gen/i486-linux-gnu/bin/simple /opt/dev/bugs/make/arena/gen/i486-linux-gnu/obj/macro_test/simple/simple.o
Made simple
remake[3]: Leaving directory `/opt/dev/bugs/make/arena/src/macro_test/simple'
Make [simple] complete
Recurse [simple] complete
Post-recurse [simple] complete
remake[2]: Leaving directory `/opt/dev/bugs/make/arena/src/macro_test'
*** glibc detected *** remake: free(): invalid pointer: 0x08080a20 ***
======= Backtrace: =========
======= Memory map: ========
08048000-08073000 r-xp 00000000 08:05 3255662 /usr/bin/remake
08073000-08075000 rw-p 0002a000 08:05 3255662 /usr/bin/remake
08075000-08097000 rw-p 08075000 00:00 0 [heap]
b7a00000-b7a21000 rw-p b7a00000 00:00 0
b7a21000-b7b00000 ---p b7a21000 00:00 0
b7be9000-b7bf3000 r-xp 00000000 08:05 1818689 /lib/
b7bf3000-b7bf4000 rw-p 0000a000 08:05 1818689 /lib/
b7c0d000-b7c0e000 rw-p b7c0d000 00:00 0
b7c10000-b7c4f000 r--p 00000000 08:05 3277973 /usr/lib/locale/en_IE.utf8/LC_CTYPE
b7c4f000-b7d30000 r--p 00000000 08:05 3277972 /usr/lib/locale/en_IE.utf8/LC_COLLATE
b7d30000-b7d31000 rw-p b7d30000 00:00 0
b7d31000-b7d33000 r-xp 00000000 08:05 1836376 /lib/tls/i686/cmov/
b7d33000-b7d35000 rw-p 00001000 08:05 1836376 /lib/tls/i686/cmov/
b7d35000-b7d36000 rw-p b7d35000 00:00 0
b7d36000-b7d63000 r-xp 00000000 08:05 1818705 /lib/
b7d63000-b7d66000 rw-p 0002c000 08:05 1818705 /lib/
b7d66000-b7d7a000 r-xp 00000000 08:05 1836396 /lib/tls/i686/cmov/
b7d7a000-b7d7c000 rw-p 00013000 08:05 1836396 /lib/tls/i686/cmov/
b7d7c000-b7d7e000 rw-p b7d7c000 00:00 0
b7d7e000-b7ec7000 r-xp 00000000 08:05 1836370 /lib/tls/i686/cmov/
b7ec7000-b7ec8000 r--p 00149000 08:05 1836370 /lib/tls/i686/cmov/
b7ec8000-b7eca000 rw-p 0014a000 08:05 1836370 /lib/tls/i686/cmov/
b7eca000-b7ecd000 rw-p b7eca000 00:00 0
b7ecd000-b7ef9000 r-xp 00000000 08:05 1818745 /lib/
b7ef9000-b7efd000 rw-p 0002c000 08:05 1818745 /lib/
b7efd000-b7efe000 rw-p b7efd000 00:00 0
b7efe000-b7f05000 r-xp 00000000 08:05 1836400 /lib/tls/i686/cmov/
b7f05000-b7f07000 rw-p 00006000 08:05 1836400 /lib/tls/i686/cmov/
b7f07000-b7f08000 rw-p b7f07000 00:00 0
b7f10000-b7f11000 r--p 00000000 08:05 3277978 /usr/lib/locale/en_IE.utf8/LC_NUMERIC
b7f11000-b7f12000 r--p 00000000 08:05 3277981 /usr/lib/locale/en_IE.utf8/LC_TIME
b7f12000-b7f13000 r--p 00000000 08:05 3277976 /usr/lib/locale/en_IE.utf8/LC_MONETARY
b7f13000-b7f14000 r--p 00000000 08:05 3285004 /usr/lib/locale/en_IE.utf8/LC_MESSAGES/SYS_LC_MESSAGES
b7f14000-b7f15000 r--p 00000000 08:05 3277979 /usr/lib/locale/en_IE.utf8/LC_PAPER
b7f15000-b7f16000 r--p 00000000 08:05 3277977 /usr/lib/locale/en_IE.utf8/LC_NAME
b7f16000-b7f17000 r--p 00000000 08:05 3277971 /usr/lib/locale/en_IE.utf8/LC_ADDRESS
b7f17000-b7f18000 r--p 00000000 08:05 3277980 /usr/lib/locale/en_IE.utf8/LC_TELEPHONE
b7f18000-b7f19000 r--p 00000000 08:05 3277975 /usr/lib/locale/en_IE.utf8/LC_MEASUREMENT
b7f19000-b7f20000 r--s 00000000 08:05 1679599 /usr/lib/gconv/gconv-modules.cache
b7f20000-b7f21000 r--p 00000000 08:05 3277974 /usr/lib/locale/en_IE.utf8/LC_IDENTIFICATION
b7f21000-b7f22000 rw-p b7f21000 00:00 0
b7f22000-b7f23000 r-xp b7f22000 00:00 0 [vdso]
b7f23000-b7f3d000 r-xp 00000000 08:05 1818644 /lib/
b7f3d000-b7f3f000 rw-p 00019000 08:05 1818644 /lib/
bf963000-bf979000 rw-p bffea000 00:00 0 [stack]
src.mak:17: *** [macro_test] Aborted

#0 macro_test at /opt/dev/bugs/make/arena/src/src.mak:17
#1 all at /opt/dev/bugs/make/arena/src/src.mak:17
remake[1]: Leaving directory `/opt/dev/bugs/make/arena/src'
Command-line arguments:
        "-C src -I /opt/dev/bugs/make/arena/src -f src.mak"
makefile:4: *** [all] Error 2

#0 all at /opt/dev/bugs/make/arena/makefile:4
Command-line arguments: none

Try moving the project tree around your hard disk and/or add comments to the include files to see how things change.

I'm sorry that remake was unlucky to be the project to exhibit this bug - it just happened to be the loser when I copied this bare-bones example into my bug staging area - make works in "/opt/dev/bugs/make", but neither build program works in "/opt/dev"!

Also, as a remake newbie; when it comes to macros, is there a way of viewing macro expansions?

Revision history for this message
Philip Ashmore (contact-philipashmore) wrote :
Revision history for this message
Philip Ashmore (contact-philipashmore) wrote :

Modifying debian/rules by adding "--with-dmalloc" to the ./configure invokation and rebuilding provides an interim solution.
The package would then require libdmalloc5 (5.5.1-1) in addition for installation.

Should I report this against the "make" package as well ?

I'll leave it to your judgement as only you will know if this is relevant to "upstream" - in your case, "make".

Revision history for this message
Rocky (rocky-bernstein) wrote :

remake and debian have versions based on GNU Make 3.81. If I recall correctly some of the memory errors were addressed between GNU Make 3.80 and 3.81.

That said, it's still possible there's a memory leak in 3.81 and it's also possible remake introduces one where there isn't one in GNU Make 3.81 :-)

But I can assure you that at least from the remake side, this will be a more fruitful line of attack.

Revision history for this message
Rockyb (rockyb) wrote :

Please try with recently release 3.82+dbg0.9

Revision history for this message
Rocky (rocky-bernstein) wrote :

Can we close this off? We're talking about code from 2007 and 9 releases ago. If it really is important to worry about this, why not just refresh with a later release?

Revision history for this message
Philip Ashmore (contact-philipashmore) wrote :

Since I went to the trouble of providing code that reveals the problem, any chance of trying it with the new release?
I've moved on since then - I know make still has bugs and I'm working on a replacement.
Test it, don't test it, close it, whatever you like.

Revision history for this message
Rockyb (rockyb) wrote :

Tried the attached project and it works for me. If I don't hear otherwise, I'll try closing this in a couple of days.

Revision history for this message
Rocky (rocky-bernstein) wrote :

Fix is to upgrade to a newer version of the code such 3.82+dbg0.9

Changed in remake (Ubuntu):
assignee: nobody → Rocky (rocky-bernstein)
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers