[bug #62615] Fix the leaks of file->cmds and file->cmds->commands

2022-06-15 Thread Dmitry Goncharov
Follow-up Comment #1, bug #62615 (project make):

Paul, can you please ignore this patch?
This bug report is correct, there is a memory leak.
But the patch is not correct. The patch fails to take into account a case when
multiple targets are defined on the same rule. Correctly taking care of
freeing commands in cases like


bye.o hello.o: hello.h; $(info 1 $@ from $^)
hello.o: hello.c; $(info 2 $@ from $^)


requires additional bookkeeping, like reference counters or similar. This
patch does not do any of that. 


___

Reply to this item at:

  

___
Message sent via Savannah
https://savannah.gnu.org/




[bug #62615] Fix the leaks of file->cmds and file->cmds->commands

2022-06-11 Thread Dmitry Goncharov
Additional Item Attachment, bug #62615 (project make):

File name: sv62615_fix.diff   Size:1 KB


File name: sv62615_test.diff  Size:1 KB




___

Reply to this item at:

  

___
Message sent via Savannah
https://savannah.gnu.org/




[bug #62615] Fix the leaks of file->cmds and file->cmds->commands

2022-06-11 Thread Dmitry Goncharov
URL:
  

 Summary: Fix the leaks of file->cmds and file->cmds->commands
 Project: make
   Submitter: dgoncharov
   Submitted: Sat 11 Jun 2022 01:52:52 PM UTC
Severity: 3 - Normal
  Item Group: Bug
  Status: None
 Privacy: Public
 Assigned to: None
 Open/Closed: Open
 Discussion Lock: Any
   Component Version: SCM
Operating System: Any
   Fixed Release: None
   Triage Status: None


___

Follow-up Comments:


---
Date: Sat 11 Jun 2022 01:52:52 PM UTC By: Dmitry Goncharov 
Makefile like the following causes make to leak
file->cmds along with file->cmds->commands allocated for the 1st hello.o
rule.

+++
all: hello.o
hello.o: hello.h; $(info 1 $@ from $^)
hello.o: hello.c; $(info 2 $@ from $^)


To see the leak build with -fsanitize=leak


$ make
makefile2:5: warning: overriding recipe for target 'hello.o'
makefile2:4: warning: ignoring old recipe for target 'hello.o'
2 hello.o from hello.c hello.h
make: Nothing to be done for 'all'.

=
==13813==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 56 byte(s) in 1 object(s) allocated from:
#0 0x7fb54a09bc9c in __interceptor_malloc
/var/tmp/portage/sys-devel/gcc-10.2.0-r5/work/gcc-10.2.0/libsanitizer/asan/asan_malloc_linux.cpp:145
#1 0x558a7a3aae35 in xmalloc ../src/misc.c:190
#2 0x558a7a3c1923 in record_files ../src/read.c:2011
#3 0x558a7a3b6f0d in eval ../src/read.c:1009
#4 0x558a7a3b2a3c in eval_makefile ../src/read.c:438
#5 0x558a7a3b0a38 in read_all_makefiles ../src/read.c:223
#6 0x558a7a397ff7 in main ../src/main.c:1971
#7 0x7fb54953bc4e in __libc_start_main (/lib64/libc.so.6+0x23c4e)

Indirect leak of 23 byte(s) in 1 object(s) allocated from:
#0 0x7fb54a09bc9c in __interceptor_malloc
/var/tmp/portage/sys-devel/gcc-10.2.0-r5/work/gcc-10.2.0/libsanitizer/asan/asan_malloc_linux.cpp:145
#1 0x7fb54a04660d in __interceptor_strndup
/var/tmp/portage/sys-devel/gcc-10.2.0-r5/work/gcc-10.2.0/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:395
#2 0x558a7a3aaf88 in xstrndup ../src/misc.c:252
#3 0x558a7a3c1b07 in record_files ../src/read.c:2015
#4 0x558a7a3b6f0d in eval ../src/read.c:1009
#5 0x558a7a3b2a3c in eval_makefile ../src/read.c:438
#6 0x558a7a3b0a38 in read_all_makefiles ../src/read.c:223
#7 0x558a7a397ff7 in main ../src/main.c:1971
#8 0x7fb54953bc4e in __libc_start_main (/lib64/libc.so.6+0x23c4e)

SUMMARY: AddressSanitizer: 79 byte(s) leaked in 2 allocation(s).








___

Reply to this item at:

  

___
Message sent via Savannah
https://savannah.gnu.org/