From owner-freebsd-ports Fri Oct 11 4: 0:18 2002 Delivered-To: freebsd-ports@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7172F37B401 for ; Fri, 11 Oct 2002 04:00:15 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 83D3543EC5 for ; Fri, 11 Oct 2002 04:00:14 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id g9BB0ECo073447 for ; Fri, 11 Oct 2002 04:00:14 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id g9BB0E42073438; Fri, 11 Oct 2002 04:00:14 -0700 (PDT) Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9BA6637B401 for ; Fri, 11 Oct 2002 03:58:19 -0700 (PDT) Received: from draco.macsch.com (ns1.mscsoftware.com [192.207.69.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 132AD43EAC for ; Fri, 11 Oct 2002 03:58:19 -0700 (PDT) (envelope-from gwk@mscsoftware.com) Received: from mailmuc.muc.eu.mscsoftware.com (mailmuc.muc.macsch.com [161.34.37.20]) by draco.macsch.com (8.9.3/8.9.3) with ESMTP id DAA20893 for ; Fri, 11 Oct 2002 03:57:59 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by mailmuc.muc.eu.mscsoftware.com (8.11.2/8.11.2/SuSE Linux 8.11.1-0.5) with ESMTP id g9BAsJo08424; Fri, 11 Oct 2002 12:54:19 +0200 Received: from hunter.muc.macsch.com by mailmuc.muc.eu.mscsoftware.com (AvMailGate-2.0.1.2) id 08320-52C65C00; Fri, 11 Oct 2002 12:53:37 +0200 Received: from hunter.muc.macsch.com (localhost.muc.macsch.com [127.0.0.1]) by hunter.muc.macsch.com (8.12.3/8.12.3) with ESMTP id g9BAvZE2003867; Fri, 11 Oct 2002 12:57:35 +0200 (CEST) (envelope-from gwk@hunter.muc.macsch.com) Received: (from gwk@localhost) by hunter.muc.macsch.com (8.12.3/8.12.3/Submit) id g9BAvZxV003866; Fri, 11 Oct 2002 12:57:35 +0200 (CEST) Message-Id: <200210111057.g9BAvZxV003866@hunter.muc.macsch.com> Date: Fri, 11 Oct 2002 12:57:35 +0200 (CEST) From: "Georg-W. Koltermann" To: FreeBSD-gnats-submit@FreeBSD.org Cc: Georg.Koltermann@mscsoftware.com X-Send-Pr-Version: 3.113 Subject: ports/43924: writing from JAVA to a pipe sometimes hangs Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 43924 >Category: ports >Synopsis: writing from JAVA to a pipe sometimes hangs >Confidential: no >Severity: serious >Priority: high >Responsible: freebsd-ports >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Oct 11 04:00:13 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Georg-W. Koltermann >Release: FreeBSD 4.6-RELEASE i386 >Organization: MSC.Software >Environment: System: FreeBSD hunter.muc.macsch.com 4.6-RELEASE FreeBSD 4.6-RELEASE #5: Sun Sep 22 22:13:46 CEST 2002 gwk@hunter.muc.macsch.com:/usr/obj/usr/src/sys/HUNTER i386 >Description: JAVA apparently has a problem writing to pipes. The attached program writes a bunch of zeros to the pipeline "| cat > somefile". With the FreeBSD native JDK 1.3.1 patcheset 6 it randomly hangs at various loop indices. The problem also hangs with the SUN Linux JDK 1.3.1 as long as the JDK runs with -classic. It also hangs on a Linux system with the Linux JDK 1.3.1 with -classic. So it seems there is a bug in the JDK itself. However, on any other platform than FreeBSD the JDK runs with a default of -hotspot, and with that setting the problem does not show up. On IRIX it even doesn't show up with the JDK 1.3.1 with green threads and no JIT, so there must be a way to fix it. May I ask that we try to fix this problem in the FreeBSD port, since on FreeBSD the alternative of using -hotspot are not available, or does not work reliably. >How-To-Repeat: ----------------test-case-----------snip------------- import java.io.*; public class PipeWrite { public static void usage() { System.err.println("Usage: PipeWrite outfile"); } public static void main(String argv[]) throws Exception { if (argv.length < 1) { usage(); return; } // String cmd = "/bin/sh -c 'cat >" + argv[0] + "'"; String cmd[] = { "/bin/sh", "-c", "cat >" + argv[0] }; writePipe(cmd); } private static void writePipe(String pipeCmd[]) throws Exception { Process p = Runtime.getRuntime().exec(pipeCmd); byte buffer[] = new byte[16384]; OutputStream pipe = p.getOutputStream(); InputStream stderr = p.getErrorStream(); try { for (int i = 0; i < 100; i++) { System.out.println("buffer " + i + "..."); pipe.write(buffer); System.out.println("ok"); // // The problem goes away when the following line // is uncommented: // Thread.sleep(1); } } finally { pipe.close(); System.out.println("rc=" + p.waitFor()); BufferedReader err = new BufferedReader(new InputStreamReader(stderr)); String line; while ((line = err.readLine()) != null) { System.err.println(line); } err.close(); } } } ----------------end-test-case-----------snip------------- >Fix: >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message