Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GNU Make "Abort trap: 6" after gcc call however call is valid when executed alone

I am using GNU Make to build a C/C++ project that many people will use. The makefile attempts to be general because there are many optional files in this project and each user selects those files through a MATLAB interface which are then provided to the makefile via command line arguments (make target OPTS='XYZ' etc...).

When I use the makefile it correctly identifies the correct object dependencies, then proceeds to find the source prerequisites for those objects and build them. However, every time it tries to execute an object rule I get an error saying "Abort trap: 6" right after the gcc call.

The Makefile is as follows

vpath %.c $(PATH) $(OBJ_DIR)
# Pick compilers
CC1=g++
CC2=gcc
LNK=g++
# Assign variables for c/cpp implicit rules
CXXFLAGS= $(CCFLAGS) $(DEFINES) $(INCLUDES)
CFLAGS = $(CCFLAGS) $(DEFINES) $(INCLUDES)

# Assign various user-defined values
OUTPUT = -o $(USER_LIB)
C_OBJECTS = $(patsubst %.c,$(OBJ_DIR)/%.o,$(C_SOURCES))
CPP_OBJECTS = $(patsubst %.cpp,$(OBJ_DIR)/%.o,$(CPP_SOURCES))
OBJECTS = $(C_OBJECTS) $(CPP_OBJECTS) $(SIM_OBJECTS)

# User Library Dependencies and Compilation Rules
$(USER_LIB): $(OBJECTS)
    $(LNK) $(LINKERFLAGS) $(CCFLAGS) $(DEFINES) $(INCLUDES) $(OUTPUT) $(OBJECTS)

$(OBJ_DIR)/%.o: %.c 
    $(CC2) $(CFLAGS) -c -o $@ $<

and an example of what I get is:

gcc -g -D(the defines)  -I(all the includes) -c -o obj1/xyz.o ../common/xyz.c
make: *** [obj1/xyz.o] Abort trap: 6

However if I take that EXACT same gcc call and run it on the command line (just copy and paste) the file is correctly compiled and the object file placed in the obj1 folder.

I tried to look at 'make -d' to see if I could find anything either. Since that output is crazy long, the gist of it is the following:

... output truncated for brevity ...
gcc -g -D(the defines)  -I(all the includes) -c -o obj1/xyz.o ../common/xyz.c
Putting child 0x104f13cc0 (obj1/xyz.o) PID 24557 on the chain.
Live child 0x104f13cc0 (obj1/xyz.o) PID 24557 
Reaping losing child 0x104f13cc0 PID 24557 
make: *** [obj1/xyz.o] Abort trap: 6
Removing child 0x104f13cc0 PID 24557 from chain.

at which point the output ends. I also tried running make -k to see what happens after the first error. Every single source file produces the same result. Again, each source file is compilable with the exact call that make uses when done independently.

I'm completely lost on this one at this point and theres very little information about what "Abort trap: 6" means in this context.

I am running Mac OSX 10.7 with gcc-4.2 installed through Xcode.

I realize there isn't a rule for .cpp files currently, I do not at present have any .cpp source files to compile, though in the future there likely will be which is why there is support structure for it so far.

Thank you in advance for anyone who can help me.

EDIT: Added one proceeding line from the "make -d" output. EDIT: Added solution (moved to an answer)

like image 532
Alex Buck Avatar asked Feb 21 '13 21:02

Alex Buck


1 Answers

With help, answered my own question. SOLVED: First see @MadScientist's comment for what "Abort trap: 6" is.

Given that clue I realized I use a variable that could be confused with a system variable, $(PATH). It appears Make was not interpreting the following line how I expected it:

vpath %.c $(PATH) $(OBJ_DIR)                        <------ Bad

It looks like there is some interference with the system variable $(PATH) which may have been causing problems. Simply changing the vpath variable to $(SRC_PATH) eliminates the conflict with the system variable and any potential interference, thus fixing the problem.

vpath %.c $(SRC_PATH) $(OBJ_DIR)                    <------ Good

Lesson Learned: Be careful with variable names and know what your environment variables are.

Credit to @MadScientist for pointing out what "Abort trap: 6" means and suggesting environment issues.

like image 162
Alex Buck Avatar answered Nov 13 '22 11:11

Alex Buck