From nobody@FreeBSD.org  Mon Oct 27 08:26:04 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 946C51065685
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 27 Oct 2008 08:26:04 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 836CB8FC1B
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 27 Oct 2008 08:26:04 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id m9R8Q4VS037574
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 27 Oct 2008 08:26:04 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id m9R8Q4Rf037573;
	Mon, 27 Oct 2008 08:26:04 GMT
	(envelope-from nobody)
Message-Id: <200810270826.m9R8Q4Rf037573@www.freebsd.org>
Date: Mon, 27 Oct 2008 08:26:04 GMT
From: Nikolay Denev <ndenev@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: jdk1.5 Querying JMX mbean OperatingSystem->TotalPhysicalMemorySize crashes the VM on 64bit archs.
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         128411
>Category:       java
>Synopsis:       jdk1.5 Querying JMX mbean OperatingSystem->TotalPhysicalMemorySize crashes the VM on 64bit archs.
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    glewis
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Oct 27 08:30:06 UTC 2008
>Closed-Date:    Tue Feb 02 06:36:41 UTC 2010
>Last-Modified:  Tue Feb 02 06:36:41 UTC 2010
>Originator:     Nikolay Denev
>Release:        7.1-PRERELEASE
>Organization:
>Environment:
FreeBSD XXX 7.1-PRERELEASE FreeBSD 7.1-PRERELEASE #1: Wed Oct 22 15:35:49 UTC 2008     root@XXX:/usr/obj/usr/src/sys/CORE2  amd64
>Description:
The FreeBSD specific part of the OperationgSystem mbean uses sysctl(3) to query various parameters related to memory usage.
The sysctl(3) call requires an argument of type 'size_t' to set the size of the reqested value but in one
place the bsd-jdk15-patchset uses variable of type 'int' for this, which does not work correctly because
int is 32bits and size_t is 64bits on 64bit archs.
Querying this attribute (TotalPhysicalMemorySize) results in VM crash.
>How-To-Repeat:
Start an application with remote JMX enabled and connect to it with jconsole.
>Fix:
The attached patch to the bsd-jdk15-patchset8 fixes the problem.

Patch attached with submission follows:

--- jdk15.patches	2008-02-05 07:01:27.000000000 +0200
+++ jdk15.patches.fixed	2008-10-24 11:58:53.000000000 +0300
@@ -90835,7 +90835,7 @@
+#ifdef _ALLBSD_SOURCE
+    unsigned long result;
+    int mib[2];
-+    int rlen;
++    size_t rlen;
+
+    mib[0] = CTL_HW;
+    mib[1] = HW_PHYSMEM;


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-java->glewis 
Responsible-Changed-By: glewis 
Responsible-Changed-When: Mon Nov 3 15:22:10 UTC 2008 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=128411 
State-Changed-From-To: open->closed 
State-Changed-By: glewis 
State-Changed-When: Tue Feb 2 06:36:10 UTC 2010 
State-Changed-Why:  
Thanks!  It looks like the current patches for the jdk15 port have this fix 
in them. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=128411 
>Unformatted:
