Re: Segmentation fault in make-3.81

2009-07-31 Thread Philip Guenther
On Fri, Jul 31, 2009 at 8:03 AM, Glenn
Coombs wrote:
...
> I encountered this issue when I added the eval at line 18 so that I could
> set CHIPNAME to the uppercase of the filename stub.

Is there some reason that you didn't use the solution that works in
every version of make that has ever been written and instead used a
complex solution that only has a chance of working in the most recent
versions of a single make implementation?

%_struct.h: %_struct.def
ifdef VERBOSE
CHIPNAME=`echo $* | tr a-z A-Z` ; \
$(REGCONV) -chipname $$CHIPNAME $< -simout $@
else
@CHIPNAME=`echo $* | tr a-z A-Z` ; \
echo Creating regconv header file CHIPNAME=$$CHIPNAME: $(notdir $@) ; \
$(REGCONV) -chipname $$CHIPNAME $< -simout $@
endif


If the duplication bugs you:

set_chipname = CHIPNAME=`echo $* | tr a-z A-Z`
regconv = $(REGCONV) -chipname $$CHIPNAME $< -simout $@
ifdef VERBOSE
  describe = echo "$(regconv)"
else
  describe = echo "Creating regconv header file CHIPNAME=$$CHIPNAME:
$(notdir $@)"
endif

%_struct.h: %_struct.def
@${set_chipname}; ${describe}; ${regconv}


(Yeah, it's a bug in make that it crashes on your makefile...but that
makefile just seems like the wrong way to solve your problem.)


Philip Guenther


___
Bug-make mailing list
Bug-make@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-make


Segmentation fault in make-3.81

2009-07-31 Thread Glenn Coombs
Hi,

The attached makefile causes a segmentation fault if run with make -j2 (or
anything higher than -j1).  It does sometimes run with no error but 50% of
the time I get a segmentation fault.  This is on a machine running CentOS
release 4.6, kernel 2.6.9-67.ELsmp.  To reproduce just run:

make setup
make -j2

I encountered this issue when I added the eval at line 18 so that I could
set CHIPNAME to the uppercase of the filename stub.  The problem disappears
if either line 18 (the eval) or line 23 (the echo command) are commented
out.  Alternatively if I replace the echo command with a $(info message)
equivalent then the issue also disappears.

%_struct.h: %_struct.def
$(eval CHIPNAME := $(shell echo $* | tr a-z A-Z))# line
18
ifdef VERBOSE
$(REGCONV) -chipname $(CHIPNAME) $< -simout $@
else
#   $(info Creating regconv header file CHIPNAME=$(CHIPNAME): $(notdir $@))
@echo Creating regconv header file CHIPNAME=$(CHIPNAME): $(notdir
$@)
# line 23
@$(REGCONV) -chipname $(CHIPNAME) $< -simout $@
endif

The stacktrace from gdb looks like this:

% gdb ~/bin/make core.18433
GNU gdb Red Hat Linux (6.3.0.0-1.153.el4rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu"...Using host
libthread_db library "/lib64/tls/libthread_db.so.1".

Reading symbols from shared object read from target memory...done.
Loaded system supplied DSO at 0xe000
Core was generated by `make -j3'.
Program terminated with signal 11, Segmentation fault.

warning: svr4_current_sos: Can't read pathname for load map: Input/output
error

Reading symbols from /lib/tls/librt.so.1...done.
Loaded symbols for /lib/tls/librt.so.1
Reading symbols from /lib/tls/libc.so.6...done.
Loaded symbols for /lib/tls/libc.so.6
Reading symbols from /lib/tls/libpthread.so.0...done.
Loaded symbols for /lib/tls/libpthread.so.0
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
#0  eval_buffer (buffer=0x8077a50 "CHIPNAME := FOO2") at read.c:430
430   ebuf.floc = *reading_file;
(gdb) bt
#0  eval_buffer (buffer=0x8077a50 "CHIPNAME := FOO2") at read.c:430
#1  0x08050012 in func_eval (o=0x8077981 "\233]", argv=0x0,
funcname=0x8062e38 "eval") at function.c:1369
#2  0x080506a8 in expand_builtin_function (o=0x8077981 "\233]",
argc=134707792, argv=0xb870, entry_p=0xffee) at function.c:2115
#3  0x08050819 in handle_function (op=0xb904, stringp=0x8076802) at
function.c:2213
#4  0x0804c630 in variable_expand_string (line=0x0, string=0x80767d0
"\t$(eval CHIPNAME := $(shell echo $* | tr a-z A-Z))", length=-1) at
expand.c:253
#5  0x0804c9a6 in variable_expand (line=0x80767d0 "\t$(eval CHIPNAME :=
$(shell echo $* | tr a-z A-Z))") at expand.c:418
#6  0x0804ca40 in variable_expand_for_file (line=0xffee , file=0x8077a50) at expand.c:463
#7  0x0804cc15 in allocated_variable_expand_for_file (line=0x80767d0
"\t$(eval CHIPNAME := $(shell echo $* | tr a-z A-Z))", file=0x8073ce8) at
expand.c:548
#8  0x08053319 in new_job (file=0x8073ce8) at job.c:1600
#9  0x0805c28a in update_file_1 (file=0x8073ce8, depth=2) at remake.c:761
#10 0x0805b984 in update_file (file=0x8073ce8, depth=2) at remake.c:307
#11 0x0805cc73 in check_dep (file=0x8073ce8, depth=2, this_mtime=1,
must_make_ptr=0xbb34) at remake.c:947
#12 0x0805bdff in update_file_1 (file=0x8072d00, depth=1) at remake.c:508
#13 0x0805b984 in update_file (file=0x8072d00, depth=0) at remake.c:307
#14 0x0805b63f in update_goal_chain (goals=0x8076ea8) at remake.c:154
#15 0x080551a2 in main (argc=2, argv=0xd514, envp=0xd520) at
main.c:2198

--
Glenn


makefile
Description: Binary data
___
Bug-make mailing list
Bug-make@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-make


[bug #27148] Use of strcpy on overlapping memory areas

2009-07-31 Thread anonymous

URL:
  

 Summary: Use of strcpy on overlapping memory areas
 Project: make
Submitted by: None
Submitted on: Птн 31 Июл 2009 12:13:56
Severity: 3 - Normal
  Item Group: Bug
  Status: None
 Privacy: Public
 Assigned to: None
 Open/Closed: Open
 Discussion Lock: Any
   Component Version: 3.81
Operating System: Any
   Fixed Release: None

___

Details:

This bug report in Red Hat bugzilla has a nice reproducer and valgrind
citation:
https://bugzilla.redhat.com/show_bug.cgi?id=514721

The problem is that in job.c:new_job, when copying the rest of the string
after the last $ expansion, the areas may overlap.  I'll attach proposed patch
(formed against today's CVS) that replaces strcpy with memmove+strlen. 
Alternative solution would be to simply replace offending strcpy with while
(*out++ = *in++);.  Hard to say which of these will be more efficient.



___

File Attachments:


---
Date: Птн 31 Июл 2009 12:13:57  Name: make-3.81-strcpy-overlap.patch 
Size: 595B   By: None



___

Reply to this item at:

  

___
  Message sent via/by Savannah
  http://savannah.gnu.org/



___
Bug-make mailing list
Bug-make@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-make