From owner-freebsd-threads@FreeBSD.ORG Thu Jul 19 18:41:58 2012 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BE97F106566C for ; Thu, 19 Jul 2012 18:41:58 +0000 (UTC) (envelope-from freebsdml@marino.st) Received: from shepard.synsport.net (mail.synsport.com [208.69.230.148]) by mx1.freebsd.org (Postfix) with ESMTP id 96F2D8FC12 for ; Thu, 19 Jul 2012 18:41:58 +0000 (UTC) Received: from [192.168.0.225] (atoulouse-256-1-140-121.w90-45.abo.wanadoo.fr [90.45.187.121]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by shepard.synsport.net (Postfix) with ESMTP id 5C28043B97 for ; Thu, 19 Jul 2012 13:41:57 -0500 (CDT) Message-ID: <500854EC.3040305@marino.st> Date: Thu, 19 Jul 2012 20:41:48 +0200 From: John Marino User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0) Gecko/20120129 Thunderbird/10.0 MIME-Version: 1.0 To: freebsd-threads@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Fingerpointing about broken Ada tasking starting with FreeBSD 9.0 threading X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Jul 2012 18:41:58 -0000 Hi guys, it's been a while. Before FreeBSD 9.0 was released, we made sure lang/gnat-aux built on it, and it did. It wasn't until after it was released that we realized that the Ada compiler GNAT tasking was broken. lang/gnat-aux is based on gcc-4.6. I brought this to Adacore's attention as they maintain the Ada compiler in GCC. They blew it off and said, "try gcc 4.7 first". It was true that a lot of tasking code had changed, but I ported some of it to gnat-aux and it didn't fix a thing, so I wasn't too hopeful. I finally got around to building gcc-4.7 and sure enough, it's tasking is just as broken. The pending port lang/gcc-aux is here: http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/169951 The problem appears to stem from this commit: "Convert thread list lock from mutex to rwlock." by davidxu https://github.com/freebsd/freebsd/commit/c741b41fb2a88f630e77ada2888443e3fea358c9 When an Ada task exits (not sure if it's all tasks or just some of them, but it seems to be all), it aborts with the message "thread exits with resources held!" I brought this back to Adacore and said that message was caused by either a locklevel > 0 or a critical_count > 0. At that point, they said they needed a lot more convincing that it was a posix-wide problem that FreeBSD just happened to detect. (it turns out that critical_count is the culprit by the way.) The DragonFly BSD threading library has the same locklevel and critical_count thread properties, but putting the same THR_IN_CRITICAL panic in that library did NOT result in thread panics on DragonFly. All the Ada task tests passed completely. That strengthens Adacore's position that FreeBSD is "fishy" and coming up with false positives. NetBSD's thread library is too different to try to check there. If I remove > #if defined(_PTHREADS_INVARIANTS) > if (THR_IN_CRITICAL(curthread)) > PANIC("thread exits with resources held!"); > #endif then tasking tests pass on FreeBSD as well. Unfortunately there doesn't seem to be any way to disable the check without modifying and rebuilding the libpthread So what can I do? My first blame was aimed towards GCC and GNAT, but now I'm not so sure. And if, in the worst case, this is actually a FreeBSD threading bug, how can it be worked around for FreeBSD 9? I haven't been very successful using GDB to troubleshoot this thing. Regards, John