From owner-freebsd-java@FreeBSD.ORG Tue Jan 29 20:47:46 2013 Return-Path: Delivered-To: freebsd-java@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 86AA32EE for ; Tue, 29 Jan 2013 20:47:46 +0000 (UTC) (envelope-from pphillips@experts-exchange.com) Received: from mail.l3.redsrci.com (mail.pub.l3.redsrci.com [64.156.132.251]) by mx1.freebsd.org (Postfix) with ESMTP id 6C6B6740 for ; Tue, 29 Jan 2013 20:47:46 +0000 (UTC) Received: from mail.l3.redsrci.com (localhost [127.0.0.1]) by mail.l3.redsrci.com (Postfix) with ESMTP id CD2EC6F1B99 for ; Tue, 29 Jan 2013 12:47:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= experts-exchange.com; h=content-transfer-encoding:content-type :content-type:subject:subject:mime-version:user-agent:from:from :date:date:message-id:received:received; s=ee; t=1359492459; x= 1361306859; bh=Rdx0rSWoyaZM7lZjhKfwc2SK1+q2vWyOu+4LjvoVl44=; b=o pFc6Bq3hCyKZoDSvq8R2b8IjHwwp6/DGPbSPne3dTEy/GRkQoqEzjYnBG8VsHKbe eBa56bCATq6ZKHoAjnlKlUhZ0JUXMjuIwMwTwwbd1oPagb72Df06h2R2zDiNNXGS 0UpyRMb6A3HpUePCN4YpkdN/GOQZmcvLJGNE2Lqb8Y= X-Virus-Scanned: amavisd-new at redsrci.com Received: from mail.l3.redsrci.com ([127.0.0.1]) by mail.l3.redsrci.com (mail.l3.redsrci.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PlnM6E3wSbin for ; Tue, 29 Jan 2013 12:47:39 -0800 (PST) Received: from [192.168.103.98] (fw1.pub.noc.redsrci.com [72.29.164.238]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: pphillips) by mail.l3.redsrci.com (Postfix) with ESMTPSA id A39106F1B98 for ; Tue, 29 Jan 2013 12:47:39 -0800 (PST) Message-ID: <5108356B.1060008@experts-exchange.com> Date: Tue, 29 Jan 2013 12:47:39 -0800 From: Phil Phillips User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: freebsd-java@freebsd.org Subject: OpenJDK7: libnet.so getting closed twice Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Jan 2013 20:47:46 -0000 Hey all, I have some code running on the latest version of OpenJDK7. In one thread, it opens a ServerSocket. In another, it loads a configuration file. Once in a while, the config file fails to load with: Caused by: java.io.FileNotFoundException: global.properties (Bad file descriptor) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.(FileInputStream.java:138) at java.io.FileInputStream.(FileInputStream.java:97) at java.io.FileReader.(FileReader.java:58) Digging in a little deeper with truss, I see something like: open("/usr/local/openjdk7/jre/lib/amd64/libnet.so",O_RDONLY,01) = 63 (0x3f) close(63) = 0 (0x0) close(63) ERR#9 'Bad file descriptor'\ ... open("global.properties",O_RDONLY,00) = 63 (0x3f) fstat(63,{ mode=-rw-rw-r-- ,inode=32200398,size=18260,blksize=16384 }) = 0 (0x0) fcntl(63,F_GETFD,) libnet.so is getting opened (interestingly, not read - though it was read previously) and then closed *twice*. It looks like there's a race condition that can cause the "bad file descriptor" error if: 1) libnet.so opened 2) libnet.so closed (1st time) 3) config file opened (inherits now-free file descriptor) 4) libnet.so closed (2nd time - invalidates file descriptor for config file) I don't see this kind of behavior in OpenJDK6. Does anyone know what might cause libnet.so to be closed twice in OpenJDK7? Thanks, Phil