From patchwork Mon Feb 27 16:41:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jack Howarth X-Patchwork-Id: 143225 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id F0828B6FA5 for ; Tue, 28 Feb 2012 03:41:53 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1330965714; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=uump5gau3NO9mQ3pRu7BYZQnjsk=; b=isWejP+3YzyOohF 9cnm1tYHQCQq8V3/wbO4NTkbrdaaiAGKY5Du14v9SS2UtVOv40CggbND7WeqiGwC L17XzsYXNY2ZJmZG92Y/nRUa5IxXglh31FN73PmpCt1/0K3BperDZpdMc3yp2n4w L6YVsloZ1HQmkgcI/z4p8FdnwblQ= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=przEzbedDmEV5zxN4CtSF+oA8lGDDEQMS5mWb4oM2MK1jnITunaUEiEE/QYjq/ rub3wbAm+DAEHzkeH59/7RbgoFQ2oM5b/vnWrHPEPvivhT1fXGbVIiFl87cYNgfa Zg2A3Ym3JR6u3mOMrfy6YOg7PmboJpbczX16b2xA7VQbg=; Received: (qmail 21202 invoked by alias); 27 Feb 2012 16:41:45 -0000 Received: (qmail 21187 invoked by uid 22791); 27 Feb 2012 16:41:43 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from bromo.med.uc.edu (HELO bromo.med.uc.edu) (129.137.3.146) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 27 Feb 2012 16:41:29 +0000 Received: from bromo.med.uc.edu (localhost.localdomain [127.0.0.1]) by bromo.med.uc.edu (Postfix) with ESMTP id 7FF26B005C; Mon, 27 Feb 2012 11:41:28 -0500 (EST) Received: (from howarth@localhost) by bromo.med.uc.edu (8.14.3/8.14.3/Submit) id q1RGfRun030686; Mon, 27 Feb 2012 11:41:27 -0500 Date: Mon, 27 Feb 2012 11:41:27 -0500 From: Jack Howarth To: gcc-patches@gcc.gnu.org Cc: patrick.marlier@gmail.com, mikestump@comcast.net, iains@gcc.gnu.org, Han.Boehm@hp.com, rguenther@suse.de Subject: [PATCH] fix PR48299 by merging changes for thread_leak_test.c from upstream Message-ID: <20120227164127.GA30684@bromo.med.uc.edu> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Currently the testsuite/boehm-gc.c/thread_leak_test.c executation test will hang on several targets including x86_64-apple-darwin10/11 for -m32/-m64. The attached patch eliminates this issue, PR48299, by merging in the upstream changes for this testcase from... https://raw.github.com/ivmai/bdwgc/master/tests/thread_leak_test.c The only changes made to the upstram test case was retaining the use of... GC_find_leak = 1; rather than... GC_set_find_leak(1); and formatting style changes. Tested on x86_64-apple-darwin10 and x86_64-apple-darwin11. Okay for gcc trunk for gcc 4.7 (as the timeouts in the testsuite are very annoying)? Jack ps I was uncertain how much detail we need in the changelog as the upstream commit logs aren't very informative... https://github.com/ivmai/bdwgc/commits/master/tests/thread_leak_test.c 2012-02-27 Jack Howarth Patrick Marlier PR boehm-gc/48299 testsuite/boehm-gc.c/thread_leak_test.c: Merge upstream changes. boehm-gc/ Index: testsuite/boehm-gc.c/thread_leak_test.c =================================================================== --- testsuite/boehm-gc.c/thread_leak_test.c (revision 184602) +++ testsuite/boehm-gc.c/thread_leak_test.c (working copy) @@ -1,13 +1,22 @@ -#define GC_LINUX_THREADS +#ifndef GC_THREADS +# define GC_THREADS +#endif #include "leak_detector.h" -#include +#ifdef GC_PTHREADS +# include +#else +# include +#endif #include -void * test(void * arg) { +#ifdef GC_PTHREADS + void * test(void * arg) +#else + DWORD WINAPI test(LPVOID arg) +#endif +{ int *p[10]; int i; - GC_find_leak = 1; /* for new collect versions not compiled */ - /* with -DFIND_LEAK. */ for (i = 0; i < 10; ++i) { p[i] = malloc(sizeof(int)+i); } @@ -15,23 +24,47 @@ for (i = 1; i < 10; ++i) { free(p[i]); } -} +#ifdef GC_PTHREADS + return arg; +#else + return (DWORD)(GC_word)arg; +#endif +} #define NTHREADS 5 -int main() { +int main(void) { int i; +#ifdef GC_PTHREADS pthread_t t[NTHREADS]; +#else + HANDLE t[NTHREADS]; + DWORD thread_id; +#endif int code; + GC_find_leak = 1; /* for new collect versions not compiled */ + GC_INIT(); for (i = 0; i < NTHREADS; ++i) { - if ((code = pthread_create(t + i, 0, test, 0)) != 0) { - printf("Thread creation failed %d\n", code); +#ifdef GC_PTHREADS + code = pthread_create(t + i, 0, test, 0); +#else + t[i] = CreateThread(NULL, 0, test, 0, 0, &thread_id); + code = t[i] != NULL ? 0 : (int)GetLastError(); +#endif + if (code != 0) { + printf("Thread creation failed %d\n", code); } } for (i = 0; i < NTHREADS; ++i) { - if ((code = pthread_join(t[i], 0)) != 0) { - printf("Thread join failed %lu\n", code); +#ifdef GC_PTHREADS + code = pthread_join(t[i], 0); +#else + code = WaitForSingleObject(t[i], INFINITE) == WAIT_OBJECT_0 ? 0 : + (int)GetLastError(); +#endif + if (code != 0) { + printf("Thread join failed %d\n", code); } } CHECK_LEAKS();