Date: Fri, 18 Jan 2013 19:29:32 GMT From: Phil Phillips <pphillips@experts-exchange.com> To: freebsd-gnats-submit@FreeBSD.org Subject: ports/175417: [PATCH] java/openjdk7: Fix for OpenJDK Network Crash Message-ID: <201301181929.r0IJTWEX018906@red.freebsd.org> Resent-Message-ID: <201301181930.r0IJU0oI003774@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 175417 >Category: ports >Synopsis: [PATCH] java/openjdk7: Fix for OpenJDK Network Crash >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Jan 18 19:30:00 UTC 2013 >Closed-Date: >Last-Modified: >Originator: Phil Phillips >Release: >Organization: Experts Exchange, LLC >Environment: >Description: OpenJDK 7 is crashing during heavy use of UDP sockets. This has been traced back to a change upstream to move from a poll() to select() implementation within NET_Timeout in bsd_close.c: http://mail.openjdk.java.net/pipermail/macosx-port-dev/2012-January/002424.html Patch for java/openjdk7 to revert this change is attached. >How-To-Repeat: Run sample code found here: http://pastebin.mozilla.org/2006513 Sample crash report: http://pastebin.mozilla.org/2006530 >Fix: Patch attached with submission follows: Index: Makefile =================================================================== --- Makefile (revision 310617) +++ Makefile (working copy) @@ -7,6 +7,7 @@ PORTNAME= openjdk PORTVERSION= ${JDK_MAJOR_VERSION}.${PORT_MINOR_VERSION}.${PORT_BUILD_NUMBER} +PORTREVISION= 1 CATEGORIES= java devel MASTER_SITES= http://download.java.net/openjdk/jdk${JDK_MAJOR_VERSION}u${JDK_MINOR_VERSION}/promoted/b${JDK_BUILD_NUMBER}/ \ http://download.java.net/jaxp/1.4.5/:jaxp \ Index: files/patch-set =================================================================== --- files/patch-set (revision 310617) +++ files/patch-set (working copy) @@ -23566,6 +23566,94 @@ len = sizeof(struct sockaddr_in); } JVM_Connect(fd, (struct sockaddr *)&addr, len); +--- jdk/src/solaris/native/java/net/bsd_close.c.orig 2012-08-10 17:31:31.000000000 +0000 ++++ jdk/src/solaris/native/java/net/bsd_close.c 2013-01-18 18:36:37.000000000 +0000 +@@ -29,7 +29,6 @@ + #include <pthread.h> + #include <sys/types.h> + #include <sys/socket.h> +-#include <sys/select.h> + #include <sys/time.h> + #include <sys/resource.h> + #include <sys/uio.h> +@@ -340,13 +339,13 @@ + #endif + + /* +- * Wrapper for select(s, timeout). We are using select() on Mac OS due to Bug 7131399. ++ * Wrapper for poll(s, timeout). + * Auto restarts with adjusted timeout if interrupted by + * signal other than our wakeup signal. + */ + int NET_Timeout(int s, long timeout) { + long prevtime = 0, newtime; +- struct timeval t, *tp = &t; ++ struct timeval t; + fdEntry_t *fdEntry = getFdEntry(s); + + /* +@@ -361,35 +360,24 @@ + * Pick up current time as may need to adjust timeout + */ + if (timeout > 0) { +- /* Timed */ +- struct timeval now; +- gettimeofday(&now, NULL); +- prevtime = now.tv_sec * 1000 + now.tv_usec / 1000; +- t.tv_sec = timeout / 1000; +- t.tv_usec = (timeout % 1000) * 1000; +- } else if (timeout < 0) { +- /* Blocking */ +- tp = 0; +- } else { +- /* Poll */ +- t.tv_sec = 0; +- t.tv_usec = 0; ++ gettimeofday(&t, NULL); ++ prevtime = t.tv_sec * 1000 + t.tv_usec / 1000; + } + + for(;;) { +- fd_set rfds; ++ struct pollfd pfd; + int rv; + threadEntry_t self; + + /* +- * call select on the fd. If interrupted by our wakeup signal ++ * Poll the fd. If interrupted by our wakeup signal + * errno will be set to EBADF. + */ +- FD_ZERO(&rfds); +- FD_SET(s, &rfds); ++ pfd.fd = s; ++ pfd.events = POLLIN | POLLERR; + + startOp(fdEntry, &self); +- rv = select(s+1, &rfds, 0, 0, tp); ++ rv = poll(&pfd, 1, timeout); + endOp(fdEntry, &self); + + /* +@@ -398,16 +386,13 @@ + */ + if (rv < 0 && errno == EINTR) { + if (timeout > 0) { +- struct timeval now; +- gettimeofday(&now, NULL); +- newtime = now.tv_sec * 1000 + now.tv_usec / 1000; ++ gettimeofday(&t, NULL); ++ newtime = t.tv_sec * 1000 + t.tv_usec / 1000; + timeout -= newtime - prevtime; + if (timeout <= 0) { + return 0; + } + prevtime = newtime; +- t.tv_sec = timeout / 1000; +- t.tv_usec = (timeout % 1000) * 1000; + } + } else { + return rv; --- jdk/src/solaris/native/java/net/net_util_md.c 2012-08-10 10:31:31.000000000 -0700 +++ jdk/src/solaris/native/java/net/net_util_md.c 2013-01-16 08:58:15.000000000 -0800 @@ -45,6 +45,10 @@ >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201301181929.r0IJTWEX018906>