From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24184 invoked by alias); 14 Jul 2005 13:37:24 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 24153 invoked by uid 48); 14 Jul 2005 13:37:20 -0000 Date: Thu, 14 Jul 2005 13:38:00 -0000 Message-ID: <20050714133720.24152.qmail@sourceware.org> From: "jakub at redhat dot com" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20050705135434.22309.jakub@redhat.com> References: <20050705135434.22309.jakub@redhat.com> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug libstdc++/22309] mt allocator doesn't pthread_key_delete it's keys X-Bugzilla-Reason: CC X-SW-Source: 2005-07/txt/msg01731.txt.bz2 List-Id: ------- Additional Comments From jakub at redhat dot com 2005-07-14 13:37 ------- Another patch here: To test whether _M_get_thread_id/_M_initialize/_M_destroy_thread_key works I was using following testcase under debugger: #include #include #include #include using __gnu_cxx::__pool; using __gnu_cxx::__common_pool_policy; using __gnu_cxx::__per_type_pool_policy; typedef __common_pool_policy<__pool, true> cpolicy_type; typedef __per_type_pool_policy tpolicy_type; typedef __per_type_pool_policy upolicy_type; typedef __gnu_cxx::__mt_alloc callocator_type; typedef __gnu_cxx::__mt_alloc tallocator_type; typedef __gnu_cxx::__mt_alloc uallocator_type; typedef __gnu_cxx::__pool_base::_Tune tune_type; callocator_type ca; tallocator_type ta; uallocator_type ua; void *tf(void *arg) { callocator_type::pointer p1 = ca.allocate(128); callocator_type::pointer p2 = ca.allocate(5128); ca.deallocate(p1, 128); ca.deallocate(p2, 5128); int idx = (int) (long) arg; if (idx & 1) sleep (1); else sleep (1024); return NULL; } void *tf2(void *arg) { tallocator_type::pointer p1 = ta.allocate(128); tallocator_type::pointer p2 = ta.allocate(5128); ta.deallocate(p1, 128); ta.deallocate(p2, 5128); int idx = (int) (long) arg; if (idx & 1) sleep (1); else sleep (1024); return NULL; } void *tf3(void *arg) { uallocator_type::pointer p1 = ua.allocate(128); uallocator_type::pointer p2 = ua.allocate(5128); ua.deallocate(p1, 128); ua.deallocate(p2, 5128); int idx = (int) (long) arg; if (idx & 1) sleep (1); else sleep (1024); return NULL; } int main() { tune_type t_opt(16, 5120, 32, 5120, 20, 10, false); ca._M_set_options(t_opt); pthread_t th[48]; for (int i = 0; i < 16; ++i) pthread_create (&th[i], NULL, tf, (void *) (long) i); callocator_type::pointer p1 = ca.allocate(128); callocator_type::pointer p2 = ca.allocate(5128); ca.deallocate(p1, 128); ca.deallocate(p2, 5128); sleep (3); tune_type t_opt2(16, 5120, 32, 5120, 36, 10, false); ta._M_set_options(t_opt2); for (int i = 16; i < 32; ++i) pthread_create (&th[i], NULL, tf2, (void *) (long) i); tallocator_type::pointer p3 = ta.allocate(128); tallocator_type::pointer p4 = ta.allocate(5128); ta.deallocate(p3, 128); ta.deallocate(p4, 5128); sleep (3); tune_type t_opt3(16, 5120, 32, 5120, 52, 10, false); ua._M_set_options(t_opt3); for (int i = 32; i < 48; ++i) pthread_create (&th[i], NULL, tf3, (void *) (long) i); uallocator_type::pointer p5 = ua.allocate(128); uallocator_type::pointer p6 = ua.allocate(5128); ua.deallocate(p5, 128); ua.deallocate(p6, 5128); sleep (3); return 0; } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22309