From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21662 invoked by alias); 27 Jul 2009 14:07:02 -0000 Received: (qmail 21644 invoked by uid 22791); 27 Jul 2009 14:07:02 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_05,J_CHICKENPOX_22 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; Mon, 27 Jul 2009 14:06:48 +0000 Received: from sunsite.mff.cuni.cz (localhost [127.0.0.1]) by sunsite.mff.cuni.cz (8.14.3/8.14.3) with ESMTP id n6RE62ue010277; Mon, 27 Jul 2009 16:06:02 +0200 Received: (from jakub@localhost) by sunsite.mff.cuni.cz (8.14.3/8.14.3/Submit) id n6RE62qE010276; Mon, 27 Jul 2009 16:06:02 +0200 Date: Mon, 27 Jul 2009 14:07:00 -0000 From: Jakub Jelinek To: Ulrich Drepper Cc: Glibc hackers Subject: [PATCH] Fix STB_GNU_UNIQUE handling for > 30 unique symbols Message-ID: <20090727140602.GN3101@sunsite.ms.mff.cuni.cz> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) 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-07/txt/msg00002.txt.bz2 Hi! There were several issues when the initial 31 entries hashtab filled up. size * 3 <= tab->n_elements is always false, table can't have more elements than its size. I assume from libiberty/hashtab.c this meant to be check for 3/4 full. Even after fixing that, _dl_higher_prime_number (31) apparently returns 31, only _dl_higher_prime_number (32) returns 61. And, size variable wasn't updated during reallocation, which means during reallocation the insertion of the new entry was done into a wrong spot. All this lead to a hang in ld.so, because a search with n_elements 31 size 31 wouldn't ever terminate. 2009-07-27 Jakub Jelinek * elf/dl-lookup.c (do_lookup_x): Fix check for table more than 3/4 full. Pass size + 1 rather than size to _dl_higher_prime_number. Update size when reallocating. --- libc/elf/dl-lookup.c.jj 2009-07-23 16:44:46.000000000 +0200 +++ libc/elf/dl-lookup.c 2009-07-27 15:58:48.000000000 +0200 @@ -377,10 +377,10 @@ do_lookup_x (const char *undef_name, uin idx -= size; } - if (size * 3 <= tab->n_elements) + if (size * 3 <= tab->n_elements * 4) { /* Expand the table. */ - size_t newsize = _dl_higher_prime_number (size); + size_t newsize = _dl_higher_prime_number (size + 1); struct unique_sym *newentries = calloc (sizeof (struct unique_sym), newsize); if (newentries == NULL) @@ -398,6 +398,7 @@ do_lookup_x (const char *undef_name, uin tab->free (entries); tab->size = newsize; + size = newsize; entries = tab->entries = newentries; tab->free = free; } Jakub