From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24429 invoked by alias); 16 Apr 2009 10:36:36 -0000 Received: (qmail 24367 invoked by uid 22791); 16 Apr 2009 10:36:21 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from sunsite.ms.mff.cuni.cz (HELO sunsite.mff.cuni.cz) (195.113.15.26) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 16 Apr 2009 10:36:16 +0000 Received: from sunsite.mff.cuni.cz (localhost.localdomain [127.0.0.1]) by sunsite.mff.cuni.cz (8.13.8/8.13.8) with ESMTP id n3GAjsfq031756; Thu, 16 Apr 2009 12:45:54 +0200 Received: (from jakub@localhost) by sunsite.mff.cuni.cz (8.13.8/8.13.8/Submit) id n3GAjsAY031755; Thu, 16 Apr 2009 12:45:54 +0200 Date: Thu, 16 Apr 2009 10:36:00 -0000 From: Jakub Jelinek To: Ulrich Drepper Cc: Glibc hackers Subject: [PATCH] Fix GL(dl_nns) updating in statically linked programs Message-ID: <20090416104553.GT16681@sunsite.ms.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.4.2.2i Mailing-List: contact libc-hacker-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sourceware.org X-SW-Source: 2009-04/txt/msg00001.txt.bz2 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 * 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