Bug 175417 - [PATCH] java/openjdk7: Fix for OpenJDK Network Crash
Summary: [PATCH] java/openjdk7: Fix for OpenJDK Network Crash
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Greg Lewis
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-18 19:30 UTC by Phil Phillips
Modified: 2013-01-29 05:10 UTC (History)
0 users

See Also:


Attachments
file.diff (3.65 KB, patch)
2013-01-18 19:30 UTC, Phil Phillips
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Phil Phillips 2013-01-18 19:30:00 UTC
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.

Fix: Patch attached with submission follows:
How-To-Repeat: Run sample code found here: http://pastebin.mozilla.org/2006513
Sample crash report: http://pastebin.mozilla.org/2006530
Comment 1 Edwin Groothuis freebsd_committer 2013-01-18 19:30:08 UTC
Responsible Changed
From-To: freebsd-ports-bugs->glewis

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 dfilter service freebsd_committer 2013-01-29 05:06:57 UTC
Author: glewis
Date: Tue Jan 29 05:06:46 2013
New Revision: 311149
URL: http://svnweb.freebsd.org/changeset/ports/311149

Log:
  . Fix a crash under heavy network load by reverting to using poll(2) rather
    than select(2).
  
  PR:		175417
  Based on the patch by:	Phil Phillips <pphillips@experts-exchange.com>

Added:
  head/java/openjdk7/files/patch-bsd_close.c   (contents, props changed)
Modified:
  head/java/openjdk7/Makefile

Modified: head/java/openjdk7/Makefile
==============================================================================
--- head/java/openjdk7/Makefile	Tue Jan 29 04:03:29 2013	(r311148)
+++ head/java/openjdk7/Makefile	Tue Jan 29 05:06:46 2013	(r311149)
@@ -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 \

Added: head/java/openjdk7/files/patch-bsd_close.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/java/openjdk7/files/patch-bsd_close.c	Tue Jan 29 05:06:46 2013	(r311149)
@@ -0,0 +1,85 @@
+--- jdk/src/solaris/native/java/net/bsd_close.c	Wed Jan 16 16:04:50 2013 -0800
++++ jdk/src/solaris/native/java/net/bsd_close.c	Thu Jan 17 22:14:02 2013 -0800
+@@ -345,6 +345,76 @@
+  * signal other than our wakeup signal.
+  */
+ int NET_Timeout(int s, long timeout) {
++/*
++ * On MacOS X, poll(2) is not working correctly, so a select(2) based
++ * implementation is preferred.  See
++ *
++ * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7131399
++ *
++ * However, on FreeBSD, the select(2) based implementation can cause
++ * crashes under load and poll(2) is preferred.  See
++ *
++ * http://docs.freebsd.org/cgi/getmsg.cgi?fetch=215525+0+current/freebsd-java
++ *
++ * Other *BSD should adjust as appropriate.
++ */
++#ifdef __FreeBSD__
++    long prevtime = 0, newtime;
++    struct timeval t;
++    fdEntry_t *fdEntry = getFdEntry(s);
++
++    /*
++     * Check that fd hasn't been closed.
++     */
++    if (fdEntry == NULL) {
++        errno = EBADF;
++        return -1;
++    }
++
++    /*
++     * Pick up current time as may need to adjust timeout
++     */
++    if (timeout > 0) {
++        gettimeofday(&t, NULL);
++        prevtime = t.tv_sec * 1000  +  t.tv_usec / 1000;
++    }
++
++    for(;;) {
++        struct pollfd pfd;
++        int rv;
++        threadEntry_t self;
++
++        /*
++         * Poll the fd. If interrupted by our wakeup signal
++         * errno will be set to EBADF.
++         */
++        pfd.fd = s;
++        pfd.events = POLLIN | POLLERR;
++
++        startOp(fdEntry, &self);
++        rv = poll(&pfd, 1, timeout);
++        endOp(fdEntry, &self);
++
++        /*
++         * If interrupted then adjust timeout. If timeout
++         * has expired return 0 (indicating timeout expired).
++         */
++        if (rv < 0 && errno == EINTR) {
++            if (timeout > 0) {
++                gettimeofday(&t, NULL);
++                newtime = t.tv_sec * 1000  +  t.tv_usec / 1000;
++                timeout -= newtime - prevtime;
++                if (timeout <= 0) {
++                    return 0;
++                }
++                prevtime = newtime;
++            }
++        } else {
++            return rv;
++        }
++
++    }
++#else
+     long prevtime = 0, newtime;
+     struct timeval t, *tp = &t;
+     fdEntry_t *fdEntry = getFdEntry(s);
+@@ -414,4 +484,5 @@
+         }
+ 
+     }
++#endif
+ }
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 3 Greg Lewis freebsd_committer 2013-01-29 05:07:14 UTC
State Changed
From-To: open->closed

Committed, with minor changes. Thanks!