public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Don't call uname or getrlimit in libpthread init function
@ 2010-04-08  9:43 Andreas Schwab
  2010-04-08 22:36 ` Ulrich Drepper
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2010-04-08  9:43 UTC (permalink / raw)
  To: libc-hacker

The libpthread init function calls uname and getrlimit, which means they
are called just by being linked against it, even if the program does not
use any of the libpthread functions, thus may use the function names for
its own purpose.

Andreas.

2010-04-08  Andreas Schwab  <schwab@redhat.com>

	* sysdeps/unix/sysv/linux/i386/Versions: Export __uname under
	GLIBC_PRIVATE.
	* nptl/Versions: Export __getrlimit under GLIBC_PRIVATE.
	* sysdeps/unix/sysv/linux/i386/smp.h: Call __uname instead of uname.
	* nptl/nptl-init.c: Call __getrlimit instead of getrlimit.
---
 nptl/Versions                              |    1 +
 nptl/nptl-init.c                           |    2 +-
 nptl/sysdeps/unix/sysv/linux/i386/Versions |    6 ++++++
 nptl/sysdeps/unix/sysv/linux/i386/smp.h    |    2 +-
 4 files changed, 9 insertions(+), 2 deletions(-)
 create mode 100644 nptl/sysdeps/unix/sysv/linux/i386/Versions

diff --git a/nptl/Versions b/nptl/Versions
index 1f2de79..13ca357 100644
--- a/nptl/Versions
+++ b/nptl/Versions
@@ -29,6 +29,7 @@ libc {
   GLIBC_PRIVATE {
     # Internal libc interface to libpthread
     __libc_dl_error_tsd;
+    __getrlimit;
   }
 }
 
diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c
index 851bab2..c663f21 100644
--- a/nptl/nptl-init.c
+++ b/nptl/nptl-init.c
@@ -396,7 +396,7 @@ __pthread_initialize_minimal_internal (void)
   /* Determine the default allowed stack size.  This is the size used
      in case the user does not specify one.  */
   struct rlimit limit;
-  if (getrlimit (RLIMIT_STACK, &limit) != 0
+  if (__getrlimit (RLIMIT_STACK, &limit) != 0
       || limit.rlim_cur == RLIM_INFINITY)
     /* The system limit is not usable.  Use an architecture-specific
        default.  */
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/Versions b/nptl/sysdeps/unix/sysv/linux/i386/Versions
new file mode 100644
index 0000000..9d53804
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/i386/Versions
@@ -0,0 +1,6 @@
+libc {
+  GLIBC_PRIVATE {
+    # Internal libc interface to libpthread
+    __uname;
+  }
+}
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/smp.h b/nptl/sysdeps/unix/sysv/linux/i386/smp.h
index f68a0c0..bdff665 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/smp.h
+++ b/nptl/sysdeps/unix/sysv/linux/i386/smp.h
@@ -37,7 +37,7 @@ is_smp_system (void)
   char *cp;
 
   /* Try reading the number using `sysctl' first.  */
-  if (uname (&u.uts) == 0)
+  if (__uname (&u.uts) == 0)
     cp = u.uts.version;
   else
     {
-- 
1.7.0.1


-- 
Andreas Schwab, schwab@redhat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84  5EC7 45C6 250E 6F00 984E
"And now for something completely different."

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Don't call uname or getrlimit in libpthread init function
  2010-04-08  9:43 [PATCH] Don't call uname or getrlimit in libpthread init function Andreas Schwab
@ 2010-04-08 22:36 ` Ulrich Drepper
       [not found]   ` <m2y6gxy1po.fsf@igel.home>
  0 siblings, 1 reply; 4+ messages in thread
From: Ulrich Drepper @ 2010-04-08 22:36 UTC (permalink / raw)
  To: libc-hacker

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/08/2010 02:42 AM, Andreas Schwab wrote:
> The libpthread init function calls uname and getrlimit, which means they
> are called just by being linked against it, even if the program does not
> use any of the libpthread functions, thus may use the function names for
> its own purpose.

No, uname belongs to the namespace to the implementation.  You cannot
just overload it.  Why on earth should this be allowed?  Somebody
overloading the function has to know what s/he does.

- -- 
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAku+WnMACgkQ2ijCOnn/RHTJDQCgt1FFA25UxSXZ/m8SSmo3zmFi
VF4AnjdisA/9QcZcVTNoP87V4n3eUZVk
=1+2h
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Don't call uname or getrlimit in libpthread init function
       [not found]   ` <m2y6gxy1po.fsf@igel.home>
@ 2010-04-08 23:42     ` Ulrich Drepper
  2010-04-09  8:18       ` Andreas Schwab
  0 siblings, 1 reply; 4+ messages in thread
From: Ulrich Drepper @ 2010-04-08 23:42 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-hacker

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/08/2010 04:16 PM, Andreas Schwab wrote:
> The last time I checked, uname was not in C99.

Neither is POSIX threads.  If you link with the DSO you're leaving ISO C
territory.

And moreover: when you define a function umask in your program (= the
executable) nothing bad will happen.  Preloading, as in this case, is
something completely different.

This is just another precedence for somebody doing stupid things and
expecting nothing to break.  It's just a bad idea to encourage this.  If
you replace a function then do it right and everything will work
correctly.  If the floodgates for these kinds of changes would be opened
we would have to add a whole lot of symbols to libc.so.  This doesn't
come without a cost.

- -- 
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAku+adcACgkQ2ijCOnn/RHQvZACggj8GMPsaR0Q/sVuyjMuGmVZI
fMcAmQGquepfyCfImc3ChYoFdJtsIcVs
=GG1m
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Don't call uname or getrlimit in libpthread init function
  2010-04-08 23:42     ` Ulrich Drepper
@ 2010-04-09  8:18       ` Andreas Schwab
  0 siblings, 0 replies; 4+ messages in thread
From: Andreas Schwab @ 2010-04-09  8:18 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: libc-hacker

Ulrich Drepper <drepper@redhat.com> writes:

> If you replace a function then do it right and everything will work
> correctly.

So what's wrong with
<http://sourceware.org/ml/libc-alpha/2010-04/msg00017.html>?

Andreas.

-- 
Andreas Schwab, schwab@redhat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84  5EC7 45C6 250E 6F00 984E
"And now for something completely different."

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-04-09  8:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-08  9:43 [PATCH] Don't call uname or getrlimit in libpthread init function Andreas Schwab
2010-04-08 22:36 ` Ulrich Drepper
     [not found]   ` <m2y6gxy1po.fsf@igel.home>
2010-04-08 23:42     ` Ulrich Drepper
2010-04-09  8:18       ` Andreas Schwab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).