Serious problem with RMI on jdk15

Nikolay Denev ndenev at gmail.com
Fri Oct 24 09:00:40 UTC 2008


On 13 Oct, 2008, at 23:47 , Greg Lewis wrote:

> On Mon, Oct 13, 2008 at 05:58:58PM +0300, Nikolay Denev wrote:
>> On Oct 13, 2008, at 5:47 PM, Nikolay Denev wrote:
>>> On Oct 9, 2008, at 4:35 PM, Nikolay Denev wrote:
>>>
>>>> Hi All,
>>>>
>>>> I have the following problem : when I connect to a jmxremote
>>>> enabled application with jconsole the whole VM crashes with
>>>> segmentation fault.
>>>>
>>> [...snip...]
>>>>
>>>> I'm running amd64 7.1-PRE from yesterday, and the jdk is
>>>> jdk-1.5.0.14p8_3,1
>>>>
>>>> Any help is greatly appreciated!
>>>>
>>>> Thanks,
>>>> Nikolay Denev
>>>
>>> I think I've tracked down the problem.
>>> The JVM crashes when one requests the TotalPhysicalMemory from the
>>> OperatingSystem bean.
>>> The strange thing is that Sun specifies this value as "long", but
>>> how this can work on 64bit machines with many gigabytes of memory?
>>>
>>> What BSD patchset does is read the hw.physmem sysctl, which returns
>>> unsigned long, and then cast it to jlong and probably this is where
>>> the problem is.
>>> I've tried disabling the sysctl and hardcoding the result and my JVM
>>> does not crash anymore.
>>> Jconsole still does not show anything though.... and the same test
>>> program produces info when used with the diablo-jdk15...
>>>
>>>
>>> Regards,
>>> Nikolay Denev
>>
>> As I read this now, It's not exactly correct, longs should be 4 bytes
>> on 32bit archs, and 8bytes on 64bit archs.
>> So the storage type for TotalPhysicalMemory should be ok. Maybe jlong
>> is not correctly adjusted to 8bytes on 64bit architectures?
>
> A jlong is typedef'ed as a 'long long' on both 32 and 64 bit  
> architectures.
> How much memory does the machine have and what architecture is it?
>
> -- 
> Greg Lewis                          Email   : glewis at eyesbeyond.com
> Eyes Beyond                         Web     : http:// 
> www.eyesbeyond.com
> Information Technology              FreeBSD : glewis at FreeBSD.org

Hi Greg,

The real problem is that in the getTotalPhysicalMemory routine
the rlen variable type used in the sysctl() call is 'int' which is  
32bit, while
it needs to be 64bit size_t.

This is a patch for the bsd-jdk15-patchset version 8 :

--- 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;



--
Regards,
Nikolay Denev






More information about the freebsd-java mailing list