From owner-freebsd-bugs@FreeBSD.ORG Mon Aug 16 00:30:25 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B416A16A4CF for ; Mon, 16 Aug 2004 00:30:25 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9625A43D39 for ; Mon, 16 Aug 2004 00:30:25 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id i7G0UPAT037478 for ; Mon, 16 Aug 2004 00:30:25 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i7G0UPg4037476; Mon, 16 Aug 2004 00:30:25 GMT (envelope-from gnats) Resent-Date: Mon, 16 Aug 2004 00:30:25 GMT Resent-Message-Id: <200408160030.i7G0UPg4037476@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Jake Hamby Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 99F0C16A4CF for ; Mon, 16 Aug 2004 00:21:29 +0000 (GMT) Received: from bronco.gopix.net (gopix.net [38.118.153.46]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4E6E343D45 for ; Mon, 16 Aug 2004 00:21:29 +0000 (GMT) (envelope-from jhamby@anobject.com) Received: from localhost.my.domain (ca-stmnca-cuda2-blade8b-87.stmnca.adelphia.net [68.65.226.87]) by bronco.gopix.net (8.12.11/8.12.11) with ESMTP id i7G0LRYB008778 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 15 Aug 2004 17:21:28 -0700 Received: (from jhamby@localhost) by localhost.my.domain (8.13.1/8.13.1/Submit) id i7G0LRYC003133; Sun, 15 Aug 2004 17:21:27 -0700 (PDT) (envelope-from jhamby) Message-Id: <200408160021.i7G0LRYC003133@localhost.my.domain> Date: Sun, 15 Aug 2004 17:21:27 -0700 (PDT) From: Jake Hamby To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: kern/70502: error in new __thread local storage support X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Jake Hamby List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Aug 2004 00:30:25 -0000 >Number: 70502 >Category: kern >Synopsis: error in new __thread local storage support >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Aug 16 00:30:24 GMT 2004 >Closed-Date: >Last-Modified: >Originator: Jake Hamby >Release: FreeBSD 5.2-CURRENT i386 >Organization: Software Factory x >Environment: System: FreeBSD fuji 5.2-CURRENT FreeBSD 5.2-CURRENT #2: Sat Aug 14 19:00:56 PDT 2004 root@fuji:/usr/home/work/sys/FUJI i386 >Description: The new __thread based TLS code doesn't seem to work beyond a particular size. >How-To-Repeat: See the attached test program. On my machine, it works for NUM_KEYS=6, but with NUM_KEYS=10 I see data corruption in the TLS area, and with NUM_KEYS=64, it crashes, so the TLS region is definitely overwriting something important. $ gcc -O2 -o tls_nptl_test tls_nptl_test.c -lpthread $ ./tls_nptl_test Fatal error '_pq_remove: Not in priority queue' at line 144 in file /usr/src/lib/libpthread/thread/thr_priority_queue.c (errno = 0) Segmentation fault (core dumped) >Fix: I don't know the code well enough to suggest a fix. --- tls_nptl_test.c begins here --- /* * Test of pthreads / TLS storage. */ #define _REENTRANT #include #include #include #include #define NUM_THREADS 64 #define NUM_KEYS 64 static __thread int TLS_keys[NUM_KEYS]; static pthread_t threads[NUM_THREADS]; static void* start_routine(void *arg) { int thread_num = (int)arg; int i, err; for(i=0; i<500; i++) { if (i==17) { /* printf("Thread %d: Number 17: break for debugger\n", thread_num); */ } int j; for(j=0; jRelease-Note: >Audit-Trail: >Unformatted: