This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

src/gdb ChangeLog machoread.c


CVSROOT:	/cvs/src
Module name:	src
Changes by:	brobecke@sourceware.org	2013-06-18 23:35:37

Modified files:
	gdb            : ChangeLog machoread.c 

Log message:
	[Darwin] Fix cleanup leak in machoread.c:macho_symfile_read
	
	This patch fixes a cleanup leak in macho_symfile_read (symbol_table):
	
	symbol_table = (asymbol **) xmalloc (storage_needed);
	make_cleanup (xfree, symbol_table);
	
	Unfortunately, fixing the leak alone triggers a crash which occurs
	while loading the symbols from an executable:
	
	% gdb
	(gdb) file g_exe
	[SIGSEGV]
	
	The crash is caused by the fact that performing the cleanup
	right after the call to macho_symtab_read, as currently done,
	is too early.
	
	Indeed, references to this symbol_table get saved in the oso_vector
	global during the call to macho_symtab_read via calls to
	macho_register_oso, and those references then get accessed
	later on, when processing all the OSOs that got pushed (see
	call to macho_symfile_read_all_oso).
	
	This patch prevents this by using one single cleanup queue for
	the entire function, rather than having additional separate
	cleanup queues (Eg: for the handling of the minimal symbols),
	thus preventing the premature free'ing of the minimal_symbols
	array.
	
	Secondly, this patch takes this opportunity for avoiding the use
	of the oso_vector global, thus making it simpler to track its
	lifetime.
	
	gdb/ChangeLog:
	
	* machoread.c (oso_vector): Delete this global.
	(macho_register_oso): Add new parameter "oso_vector_ptr".
	Use it instead of the "oso_vector" global.
	(macho_symtab_read, macho_symfile_read_all_oso): Likewise.
	(macho_symfile_read): Use a local oso_vector, to be free'ed
	at the end of this function, in place of the old "oso_vector"
	global.  Update various function calls accordingly.  Use one
	single cleanup chain for the entire function.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.15713&r2=1.15714
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/machoread.c.diff?cvsroot=src&r1=1.54&r2=1.55


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]