This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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]

[MTASCsft PATCH WIP4 17/28] Thread safety documentation.


for  ChangeLog

	* manual/locale.texi: Document thread safety properties.
---
 manual/locale.texi |  148 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 148 insertions(+)

diff --git a/manual/locale.texi b/manual/locale.texi
index 2f10fcd..4afa104 100644
--- a/manual/locale.texi
+++ b/manual/locale.texi
@@ -224,6 +224,137 @@ The symbols in this section are defined in the header file @file{locale.h}.
 @comment locale.h
 @comment ISO
 @deftypefun {char *} setlocale (int @var{category}, const char *@var{locale})
+@safety{@mtunsafe{uunguard, envromt}@asunsafe{oncesafe, selfdeadlock, asmalloc, asynconsist, incansist}@acunsafe{oncesafe, incansist, lockleak, memleak, fdleak}}
+@c Uses of the global locale object are unguarded in functions that
+@c ought to be MT-Safe, so we're ruling out the use of this function
+@c once threads are started.  It takes a write lock itself, but it may
+@c return a pointer loaded from the global locale object after releasing
+@c the lock, or before taking it.
+@c This function returns a pointer read...
+@c setlocale envromt, oncesafe, asmalloc, selfdeadlock, asynconsist, incansist, memleak, fdleak, lockleak
+@c  libc_rwlock_wrlock selfdeadlock, lockleak
+@c  libc_rwlock_unlock lockleak
+@c  getenv LOCPATH envromt
+@c  malloc asmalloc, memleak
+@c  free asmalloc, memleak
+@c  new_composite_name ok
+@c  setdata ok
+@c  setname ok
+@c  _nl_find_locale envromt, oncesafe, asmalloc, selfdeadlock, asynconsist, incansist, memleak, fdleak, lockleak
+@c   getenv LC_ALL and LANG envromt
+@c   _nl_load_locale_from_archive asmalloc, memleak, fdleak
+@c    sysconf _SC_PAGE_SIZE ok
+@c    _nl_normalize_codeset asmalloc, memleak
+@c     isalnum_l ok (C locale)
+@c     isdigit_l ok (C locale)
+@c     malloc asmalloc, memleak
+@c     tolower_l ok (C locale)
+@c    open_not_cancel_2 fdleak
+@c    fxstat64 ok
+@c    close_not_cancel_no_status ok
+@c    __mmap64 memleak
+@c    calculate_head_size ok
+@c    __munmap ok
+@c    compute_hashval ok
+@c    qsort dup asmalloc, memleak
+@c     rangecmp ok
+@c    malloc asmalloc, memleak
+@c    strdup asmalloc, memleak
+@c    _nl_intern_locale_data asmalloc, memleak
+@c     malloc asmalloc, memleak
+@c     free asmalloc, memleak
+@c   _nl_expand_alias asmalloc, selfdeadlock, memleak, fdleak, lockleak
+@c    libc_lock_lock selfdeadlock, lockleak
+@c    bsearch ok
+@c     alias_compare ok
+@c      strcasecmp ok
+@c    read_alias_file asmalloc, selfdeadlock, memleak, fdleak, lockleak
+@c     fopen asmalloc, selfdeadlock, memleak, fdleak, lockleak
+@c     fsetlocking ok
+@c     feof_unlocked ok
+@c     fgets_unlocked ok
+@c     isspace ok (locale mutex is locked)
+@c     extend_alias_table memleak, asmalloc
+@c      realloc memleak, asmalloc
+@c     realloc memleak, asmalloc
+@c     fclose asmalloc, selfdeadlock, memleak, fdleak, lockleak
+@c     qsort asmalloc, memleak
+@c      alias_compare dup
+@c    libc_lock_unlock lockleak
+@c   _nl_explode_name asmalloc, memleak
+@c    _nl_find_language ok
+@c    _nl_normalize_codeset dup asmalloc, memleak
+@c   _nl_make_l10nflist asmalloc, memleak
+@c    malloc asmalloc, memleak
+@c    free asmalloc, memleak
+@c    __argz_stringify ok
+@c    __argz_count ok
+@c    __argz_next ok
+@c   _nl_load_locale asmalloc, memleak, fdleak
+@c    open_not_cancel_2 fdleak
+@c    __fxstat64 ok
+@c    close_not_cancel_no_status ok
+@c    mmap memleak
+@c    malloc asmalloc, memleak
+@c    read_not_cancel ok
+@c    free asmalloc, memleak
+@c    _nl_intern_locale_data dup asmalloc, memleak
+@c    munmap ok
+@c   __gconv_compare_alias oncesafe, asmalloc, asynconsist, selfdeadlock, memleak,incansist, fdleak, lockleak
+@c    __gconv_read_conf oncesafe, asmalloc, asynconsist, selfdeadlock, memleak,incansist, fdleak, lockleak
+@c     (libc_once-initializes gconv_cache and gconv_path_envvar; they're
+@c      never modified afterwards)
+@c     __gconv_load_cache asmalloc, memleak, fdleak
+@c      getenv GCONV_PATH envromt
+@c      open_not_cancel fdleak
+@c      __fxstat64 ok
+@c      close_not_cancel_no_status ok
+@c      mmap memleak
+@c      malloc asmalloc, memleak
+@c      __read ok
+@c      free asmalloc, memleak
+@c      munmap ok
+@c     __gconv_get_path selfdeadlock, asmalloc, lockleak, memleak, fdleak
+@c      getcwd asmalloc, memleak, fdleak
+@c      libc_lock_lock selfdeadlock, lockleak
+@c      malloc asmalloc, memleak
+@c      strtok_r ok
+@c      libc_lock_unlock lockleak
+@c     read_conf_file asmalloc, asynconsist, selfdeadlock, memleak, incansist, fdleak, lockleak
+@c      fopen asmalloc, selfdeadlock, memleak, fdleak, lockleak
+@c      fsetlocking ok
+@c      feof_unlocked ok
+@c      getdelim asmalloc, asynconsist, memleak, incansist
+@c      isspace_l ok (C locale)
+@c      add_alias
+@c       isspace_l ok (C locale)
+@c       toupper_l ok (C locale)
+@c       add_alias2 dup asynconsist, asmalloc, incansist, memleak
+@c      add_module asmalloc, memleak
+@c       isspace_l ok (C locale)
+@c       toupper_l ok (C locale)
+@c       strtol ok (glocale, but we hold the locale lock)
+@c       tfind __gconv_alias_db ok
+@c        __gconv_alias_compare dup ok
+@c       calloc asmalloc, memleak
+@c       insert_module dup asmalloc
+@c     __tfind ok (because the tree is read only by then)
+@c      __gconv_alias_compare dup ok
+@c     insert_module asmalloc
+@c      free asmalloc
+@c     add_alias2 asynconsist, asmalloc, incansist, memleak
+@c      detect_conflict ok, reads __gconv_modules_db
+@c      malloc asmalloc, memleak
+@c      tsearch __gconv_alias_db asynconsist, asmalloc, incansist, memleak
+@c       __gconv_alias_compare ok
+@c      free asmalloc
+@c    __gconv_compare_alias_cache ok
+@c     find_module_idx ok
+@c    do_lookup_alias ok
+@c     __tfind ok (because the tree is read only by then)
+@c      __gconv_alias_compare ok
+@c   strndup asmalloc, memleak
+@c   strcasecmp_l ok (C locale)
 The function @code{setlocale} sets the current locale for category
 @var{category} to @var{locale}.  A list of all the locales the system
 provides can be created by running
@@ -414,6 +545,10 @@ according to the selected locale using this information.
 @comment locale.h
 @comment ISO
 @deftypefun {struct lconv *} localeconv (void)
+@safety{@mtunsafe{staticbuf, glocale}@assafe{}@acsafe{}}
+@c This function reads from multiple components of the locale object,
+@c without synchronization, while writing to the static buffer it uses
+@c as the return value.
 The @code{localeconv} function returns a pointer to a structure whose
 components contain information about how numeric and monetary values
 should be formatted in the current locale.
@@ -680,6 +815,10 @@ was introduced.
 @comment langinfo.h
 @comment XOPEN
 @deftypefun {char *} nl_langinfo (nl_item @var{item})
+@safety{@mtsafe{}@assafe{}@acsafe{}}
+@c It calls _nl_langinfo_l with the current locale, which returns a
+@c pointer into constant strings defined in locale data structures.  It
+@c doesn't run afoul of glocale itself, but callers may.
 The @code{nl_langinfo} function can be used to access individual
 elements of the locale categories.  Unlike the @code{localeconv}
 function, which returns all the information, @code{nl_langinfo}
@@ -974,6 +1113,11 @@ locale information, making it easier for the user to format
 numbers according to these rules.
 
 @deftypefun ssize_t strfmon (char *@var{s}, size_t @var{maxsize}, const char *@var{format}, @dots{})
+@safety{@mtsafe{glocale}@asunsafe{asmalloc}@acsafe{memleak}}
+@c It (and strfmon_l) both call vstrfmon_l, which, besides accessing the
+@c locale object passed to it, accesses the active locale through
+@c isdigit (but to_digit assumes ASCII digits only).  It may call
+@c __printf_fp (glocale, asmalloc, memleak) and guess_grouping (safe).
 The @code{strfmon} function is similar to the @code{strftime} function
 in that it takes a buffer, its size, a format string,
 and values to write into the buffer as text in a form specified
@@ -1185,6 +1329,10 @@ access to the corresponding locale definitions.
 @comment GNU
 @comment stdlib.h
 @deftypefun int rpmatch (const char *@var{response})
+@safety{@mtsafe{glocale}@asunsafe{asynconsist, asmalloc, selfdeadlock, shlimb}@acunsafe{incansist, lockleak, memleak, fdleak, shlimb}}
+@c Calls nl_langinfo with YESEXPR and NOEXPR, triggering glocale, but
+@c it's regcomp and regexec that bring in all of the safety issues.
+@c regfree is also called, but it doesn't introduce any further issues.
 The function @code{rpmatch} checks the string in @var{response} whether
 or not it is a correct yes-or-no answer and if yes, which one.  The
 check uses the @code{YESEXPR} and @code{NOEXPR} data in the


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