public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Ulrich Drepper <drepper@redhat.com>
Cc: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: [PATCH] Fix GL(dl_nns) updating in statically linked programs
Date: Thu, 16 Apr 2009 10:36:00 -0000	[thread overview]
Message-ID: <20090416104553.GT16681@sunsite.ms.mff.cuni.cz> (raw)

Hi!

LC_ALL=ja_JP.UTF-8 ldconfig --help
just hangs,
LC_ALL=ja_JP ldconfig --help
prints:
ldconfig: dl-load.c:1962: _dl_map_object: Assertion `nsid < _dl_nns' �����Ԥ��ޤ���.
Aborted

The problem is the same, since the introduction of GL(dl_nns), if _dl_open
is called with __LM_ID_CALLER, but there are no shared libraries loaded at
all yet (GL(dl_nns) == 0, GL(dl_ns)[LM_ID_BASE]._ns_loaded == NULL), then
dl_open_worker sets args->nsid to LM_ID_BASE:
#ifndef SHARED
          /* In statically linked apps there might be no loaded object.  */
          if (call_map == NULL)
            args->nsid = LM_ID_BASE;
          else
#endif
but unlike calling _dl_open with LM_ID_BASE right away, GL(dl_nns) isn't set
to 1 and so dl-load.c assertion fails.

Fixed thusly, ok to commit?

2009-04-16  Jakub Jelinek  <jakub@redhat.com>

	* elf/dl-open.c (_dl_open): Bump GL(dl_nns) to 1 if no libraries
	are dlopened in statically linked program even for __LM_ID_CALLER.

--- libc/elf/dl-open.c.jj	2009-04-07 07:56:51.000000000 +0200
+++ libc/elf/dl-open.c	2009-04-16 12:25:16.000000000 +0200
@@ -580,7 +580,8 @@ no more namespaces available for dlmopen
     _dl_signal_error (EINVAL, file, NULL,
 		      N_("invalid target namespace in dlmopen()"));
 #ifndef SHARED
-  else if (nsid == LM_ID_BASE && GL(dl_ns)[LM_ID_BASE]._ns_loaded == NULL
+  else if ((nsid == LM_ID_BASE || nsid == __LM_ID_CALLER)
+	   && GL(dl_ns)[LM_ID_BASE]._ns_loaded == NULL
 	   && GL(dl_nns) == 0)
     GL(dl_nns) = 1;
 #endif


	Jakub

             reply	other threads:[~2009-04-16 10:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-16 10:36 Jakub Jelinek [this message]
2009-04-16 15:20 ` Ulrich Drepper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090416104553.GT16681@sunsite.ms.mff.cuni.cz \
    --to=jakub@redhat.com \
    --cc=drepper@redhat.com \
    --cc=libc-hacker@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).