Return-Path: Delivered-To: apmail-mina-dev-archive@www.apache.org Received: (qmail 71004 invoked from network); 4 Oct 2007 08:55:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Oct 2007 08:55:12 -0000 Received: (qmail 80397 invoked by uid 500); 4 Oct 2007 08:55:00 -0000 Delivered-To: apmail-mina-dev-archive@mina.apache.org Received: (qmail 80368 invoked by uid 500); 4 Oct 2007 08:55:00 -0000 Mailing-List: contact dev-help@mina.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@mina.apache.org Delivered-To: mailing list dev@mina.apache.org Received: (qmail 80359 invoked by uid 99); 4 Oct 2007 08:55:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Oct 2007 01:55:00 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Oct 2007 08:55:10 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 97A86714187 for ; Thu, 4 Oct 2007 01:54:50 -0700 (PDT) Message-ID: <26576379.1191488090611.JavaMail.jira@brutus> Date: Thu, 4 Oct 2007 01:54:50 -0700 (PDT) From: "Rupert Smith (JIRA)" To: dev@mina.apache.org Subject: [jira] Commented: (DIRMINA-452) IdentittyHashMap Iterator has bug in it. In-Reply-To: <8160336.1191338270584.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/DIRMINA-452?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12532362 ] Rupert Smith commented on DIRMINA-452: -------------------------------------- http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6612102 > IdentittyHashMap Iterator has bug in it. > ---------------------------------------- > > Key: DIRMINA-452 > URL: https://issues.apache.org/jira/browse/DIRMINA-452 > Project: MINA > Issue Type: Bug > Components: Core > Affects Versions: 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.1.0, 1.0.4, 1.1.1, 1.0.5, 1.1.2 > Environment: Java, all 1.5 and 1.6 versions at least. > Reporter: Rupert Smith > Fix For: 1.1.3, 2.0.0-M1 > > > There is a bug in IdentityHashMap Iterator which causes an infinite loop. This can manifest itself anywhere that the iterator.remove() method is called, in conjunction with the put() method. In particular this has been observed in the VmPipeIdleStatus checker. > Certain sequences of puts/iterator.removes cause the map to allow put() to be called with a full table. The code then loops round the table forever looking for a free slot to add the new entry to. > A bug report has been submitted to Sun for this problem. > Suggested work arounds: > Use HashMap instead of IdentityHashMap. > Do not use the remove() method on the iterator, find all elements to remove in one step, then remove in another. > Here is some sample test code that exhibits the bug in isolation. Call it repeatedly with n=1000, until it locks up: > public void testRandomPutRemove(final int n) > { > final Map idMap = new IdentityHashMap(); > final Random r = new Random(); > final float removeProbability = r.nextFloat(); > final float addProbability = r.nextFloat(); > final Queue opSequence = new LinkedList(); > Runnable tester = > new Runnable() > { > public void run() > { > for (int i = 0; i < n; i++) > { > if (r.nextFloat() < addProbability) > { > synchronized (idMap) > { > TestElement e = new TestElement(); > idMap.put(e, e); > opSequence.offer("put"); > } > } > else > { > synchronized (idMap) > { > Iterator it = idMap.keySet().iterator(); > for (int j = 0; it.hasNext(); j++) > { > it.next(); > if (r.nextFloat() < removeProbability) > { > it.remove(); > opSequence.offer("remove " + j); > } > } > } > } > } > } > }; > Thread testThread = new Thread(tester); > testThread.start(); > try > { > testThread.join(5000); > } > catch (InterruptedException e) > { > fail("Test interrupted."); > } > if (testThread.getState() == Thread.State.RUNNABLE) > { > System.out.println("opSequence = " + opSequence); > System.out.println("removeProbability = " + removeProbability); > System.out.println("addProbability = " + addProbability); > // Wait forever here, to give an opportunity to take thread/heap dumps etc. > try > { > testThread.join(); > } > catch (InterruptedException e) > { > // Ignore. > } > } > } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.