From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Thompson Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] Test for weak pairs in hash-for-each Date: Tue, 11 Mar 2014 22:06:43 -0400 Message-ID: <87vbvkw4p8.fsf@izanagi.i-did-not-set--mail-host-address--so-tickle-me> References: <87vbvotjr3.fsf@izanagi.i-did-not-set--mail-host-address--so-tickle-me> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1394590016 11502 80.91.229.3 (12 Mar 2014 02:06:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 12 Mar 2014 02:06:56 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Mar 12 03:07:05 2014 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WNYZU-000869-Kq for guile-devel@m.gmane.org; Wed, 12 Mar 2014 03:07:04 +0100 Original-Received: from localhost ([::1]:58210 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNYZU-0000PJ-64 for guile-devel@m.gmane.org; Tue, 11 Mar 2014 22:07:04 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59443) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNYZL-0000OK-PB for guile-devel@gnu.org; Tue, 11 Mar 2014 22:07:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WNYZE-0005NG-Rp for guile-devel@gnu.org; Tue, 11 Mar 2014 22:06:55 -0400 Original-Received: from na3sys009aog127.obsmtp.com ([74.125.149.107]:55083) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNYZE-0005N1-Jm for guile-devel@gnu.org; Tue, 11 Mar 2014 22:06:48 -0400 Original-Received: from mail-qa0-f51.google.com ([209.85.216.51]) (using TLSv1) by na3sys009aob127.postini.com ([74.125.148.12]) with SMTP ID DSNKUx/BNuZ3OTKE0HG3jtlUdIiay/kLIUfb@postini.com; Tue, 11 Mar 2014 19:06:48 PDT Original-Received: by mail-qa0-f51.google.com with SMTP id j7so1900957qaq.38 for ; Tue, 11 Mar 2014 19:06:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:in-reply-to:references :user-agent:date:message-id:mime-version:content-type; bh=SY09WngX2V8EmcLNqUzsv83SY7tmQTMHHErXliz/4Kc=; b=i8DPmfeoNGGRJeFF5KiAAhg4KjoBqRCwwf+bGRsbEIA2fKUD2aD7wBDK9jJPQPkPk3 lQK3ZDJWfcrythFpcJSnwXN7cV+Uv6Bs35Kg8+o4YF71zeEOZj/9LtKg0psOa4ahnpyJ rvYMCaMMMJ8OQEBUfs4TXDvHOb14waFt7iVN5eqpiK8ga/yVr6fM7t7KgPU5tKBqT9GF 7B2qHY9qatm45u/6nwHErOExxOu4iwf3J+o7AZLeeeKJ8cVl0EtfK2iOdK1QZOu0RuGg dMr3CvpqTGj7458M/5rtAkxA/Jqqkdb0Jv0j2eKJouoQDW0N6ygyjakv0i0QYqVKKXAw 3/gQ== X-Gm-Message-State: ALoCoQmJaANMyUa1H9spNyJoirexGUYJ9z6ZQ/t4bnM0UhHapIuKNZ/6XRTQarHieTRp8KA7jIONdMAQnSa31TCa8SrCHCyU4hdZ/Q6+UZ77NcuGtGtPqhVT7eUKDRKYnO1UFOALWLnPxydzOlJ9fZdwKf5tYWaxMA== X-Received: by 10.224.5.197 with SMTP id 5mr52365165qaw.72.1394590005846; Tue, 11 Mar 2014 19:06:45 -0700 (PDT) X-Received: by 10.224.5.197 with SMTP id 5mr52365162qaw.72.1394590005764; Tue, 11 Mar 2014 19:06:45 -0700 (PDT) Original-Received: from izanagi (209-6-40-86.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com. [209.6.40.86]) by mx.google.com with ESMTPSA id l6sm73757339qac.8.2014.03.11.19.06.44 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 11 Mar 2014 19:06:44 -0700 (PDT) In-Reply-To: <87vbvotjr3.fsf@izanagi.i-did-not-set--mail-host-address--so-tickle-me> User-Agent: Notmuch/0.17 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 74.125.149.107 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:16959 Archived-At: --=-=-= Content-Type: text/plain David Thompson writes: Hello, Updated patch attached that fixes a small style issue. - Dave --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Test-for-deleted-weak-pairs-in-hash-for-each.patch >From 1bbf073905bc12f80b0a32fc6311163a0b0ab849 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sat, 8 Mar 2014 17:15:52 -0500 Subject: [PATCH] Test for deleted weak pairs in hash-for-each. * libguile/hashtab.c (hash-for-each): Test for deleted weak pairs. * test-suite/tests/hash.test: Add test case. --- libguile/hashtab.c | 4 +++- test-suite/tests/hash.test | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/libguile/hashtab.c b/libguile/hashtab.c index 9107ce5..44db051 100644 --- a/libguile/hashtab.c +++ b/libguile/hashtab.c @@ -1464,7 +1464,9 @@ scm_internal_hash_for_each_handle (scm_t_hash_handle_fn fn, void *closure, handle = SCM_CAR (ls); if (!scm_is_pair (handle)) SCM_WRONG_TYPE_ARG (SCM_ARG3, buckets); - fn (closure, handle); + if (!SCM_HASHTABLE_WEAK_P (table) + || !SCM_WEAK_PAIR_DELETED_P (handle)) + fn (closure, handle); ls = SCM_CDR (ls); } } diff --git a/test-suite/tests/hash.test b/test-suite/tests/hash.test index 64d10bb..4c21d71 100644 --- a/test-suite/tests/hash.test +++ b/test-suite/tests/hash.test @@ -347,3 +347,15 @@ (pass-if (equal? 2 (hash-count (lambda (k v) (string? v)) table))))) + +;;; +;;; weak key hash table +;;; + +(with-test-prefix "weak key hash table" + (pass-if "hash-for-each after gc" + (let ((table (make-weak-key-hash-table))) + (hashq-set! table (list 'foo) 'bar) + (gc) + ;; Iterate over deleted weak ref without crashing. + (unspecified? (hash-for-each (lambda (key value) key) table))))) -- 1.8.5.3 --=-=-=--