This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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

[PATCH] One more fix for valgrind discovered problems


Hi!

_nl_unload_domain called from finddomain.c's free_mem needs steps
arrays not freed yet as well.
I have checked that -static program referencing __gconv_find_transform
and nothing else in main () sucks in both setlocale.o and finddomain.o,
so this and the previous patch shouldn't be a regression for size
of statically linked programs (if this was not the case, we could
play tricks with weak symbols etc.).

With this patch in as well as the mbsrtowcs fix from yesterday all
valgrind --tool=memcheck complains I see (and aren't suppressed)
are either false alarms (e.g. nasty warnings about regcomp.c which
tests if (dfa->nodes[node].type == CHARACTER && dfa->nodes[node].mb_partial)
but mb_partial is only initialized if type == CHARACTER; as both are
bitfields, GCC optimizes the test into (x & 0x1000ff) == 0x100001
and valgrind doesn't like that the test sees an unitialized bit)
or tests which link against -lpthread (where I expect them not to work,
as valgrind has its own libpthread).

2004-08-06  Jakub Jelinek  <jakub@redhat.com>

	* intl/finddomain.c (free_mem): Rename to...
	(_nl_finddomain_subfreeres): ... this.  Add
	__libc_freeres_fn_section.
	* intl/loadmsgcat.c (_nl_unload_domain): Add
	__libc_freeres_fn_section.
	* intl/gettextP.h (_nl_unload_domain): Move into #ifdef _LIBC.
	Add attribute_hidden.
	(_nl_findomain_subfreeres): New prototype.
	* iconv/gconv_db.c (free_mem): Call _nl_findomain_subfreeres.

--- libc/intl/finddomain.c.jj	2002-11-01 21:43:55.000000000 +0100
+++ libc/intl/finddomain.c	2004-08-05 18:17:46.000000000 +0200
@@ -1,5 +1,6 @@
 /* Handle list of needed message catalogs
-   Copyright (C) 1995-1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1995-1999, 2000, 2001, 2002, 2004
+   Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Ulrich Drepper <drepper@gnu.org>, 1995.
 
@@ -168,7 +169,10 @@ _nl_find_domain (dirname, locale, domain
 
 
 #ifdef _LIBC
-libc_freeres_fn (free_mem)
+/* This is called from iconv/gconv_db.c's free_mem, as locales must
+   be freed before freeing gconv steps arrays.  */
+void __libc_freeres_fn_section
+_nl_finddomain_subfreeres ()
 {
   struct loaded_l10nfile *runp = _nl_loaded_domains;
 
--- libc/intl/loadmsgcat.c.jj	2004-04-13 10:42:52.000000000 +0200
+++ libc/intl/loadmsgcat.c	2004-08-05 18:22:24.000000000 +0200
@@ -1387,7 +1387,7 @@ _nl_load_domain (domain_file, domainbind
 
 #ifdef _LIBC
 void
-internal_function
+internal_function __libc_freeres_fn_section
 _nl_unload_domain (domain)
      struct loaded_domain *domain;
 {
--- libc/intl/gettextP.h.jj	2002-12-11 23:58:30.000000000 +0100
+++ libc/intl/gettextP.h	2004-08-05 18:21:57.000000000 +0200
@@ -1,5 +1,5 @@
 /* Header describing internals of libintl library.
-   Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1995-1999, 2000, 2001, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Ulrich Drepper <drepper@cygnus.com>, 1995.
 
@@ -173,8 +173,6 @@ struct loaded_l10nfile *_nl_find_domain 
 void _nl_load_domain PARAMS ((struct loaded_l10nfile *__domain,
 			      struct binding *__domainbinding))
      internal_function;
-void _nl_unload_domain PARAMS ((struct loaded_domain *__domain))
-     internal_function;
 const char *_nl_init_domain_conv PARAMS ((struct loaded_l10nfile *__domain_file,
 					  struct loaded_domain *__domain,
 					  struct binding *__domainbinding))
@@ -210,6 +208,9 @@ extern char *__bindtextdomain PARAMS ((c
 				       const char *__dirname));
 extern char *__bind_textdomain_codeset PARAMS ((const char *__domainname,
 						const char *__codeset));
+extern void _nl_finddomain_subfreeres PARAMS ((void)) attribute_hidden;
+extern void _nl_unload_domain PARAMS ((struct loaded_domain *__domain))
+     internal_function attribute_hidden;
 #else
 extern char *libintl_gettext PARAMS ((const char *__msgid));
 extern char *libintl_dgettext PARAMS ((const char *__domainname,
--- libc/iconv/gconv_db.c.jj	2004-08-04 19:28:50.000000000 +0200
+++ libc/iconv/gconv_db.c	2004-08-05 18:27:42.000000000 +0200
@@ -791,6 +791,10 @@ libc_freeres_fn (free_mem)
      as ctype cleanup functions dereference steps arrays which we free below.  */
   _nl_locale_subfreeres ();
 
+  /* finddomain.c has similar problem.  */
+  extern void _nl_finddomain_subfreeres (void) attribute_hidden;
+  _nl_finddomain_subfreeres ();
+
   if (__gconv_alias_db != NULL)
     __tdestroy (__gconv_alias_db, free);
 

	Jakub


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