harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gregory Shimansky (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-1295) [classlib][net] flaw in setReuseAddrAndReusePort()
Date Mon, 28 Aug 2006 23:00:25 GMT
    [ http://issues.apache.org/jira/browse/HARMONY-1295?page=comments#action_12431092 ] 
            
Gregory Shimansky commented on HARMONY-1295:
--------------------------------------------

Well, you cannot deny that GetIntField is called in the end in native code which is the reason
for failed assertion. The field ID which is used for GetIntField is an ID of a field in java.lang.Integer
class which I think is wrong when applied to an object of java.lang.Boolean class. Alexey's
stack trace shows this and I've reproduced the same trace myself.

Also it is not setBoolSocketOption, it is setReuseAddrAndReusePort according to stack trace.

> [classlib][net] flaw in setReuseAddrAndReusePort()
> --------------------------------------------------
>
>                 Key: HARMONY-1295
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1295
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Alexey Varlamov
>            Priority: Critical
>
> The tests.api.java.net.DatagramSocketTest test crashes on assert in DRLVM : Assertion
`IsInstanceOf(env, obj, struct_Class_to_jclass(f->get_class()))' failed.
> The reason is that java.net.DatagramSocket.setReuseAddress(boolean) calls to 
> PlainDatagramSocketImpl.setOption(int optID, Object val) with Boolean value, but underlying
native code treats this value as Integer.
> Quickfix must be straightforward enough, but I inclined to blame the design of INetworkSystem.[set|get]SocketOption()
as the actual root of the evil. The problem is that this API conceals the details of contract
for particular options, and a client have to guess which type of value to pass. And the implementation
is basically an ugly switch sorting requests out to setBoolSocketOption() or setIntegerSocketOption(),
etc. Shouldn'te refactor this?
> Native stack is :
> vmcore.dll!GetIntField(JNIEnv_External * env=0x103353a8, _jobject * obj=0x0654f184, _jfieldID
* fieldID=0x05e4c088)  Line 304 + 0x3a	C++
> hyluni.dll!intValue(const JNINativeInterface_ * * env=0x103353a8, _jobject * anInteger=0x0654f184)
 Line 598 + 0x1d	C
> hyluni.dll!setReuseAddrAndReusePort(const JNINativeInterface_ * * env=0x103353a8, hysocket_struct
* hysocketP=0x00160ae0, _jobject * optVal=0x0654f184)  Line 1140	C
> hyluni.dll!Java_org_apache_harmony_luni_platform_OSNetworkSystem_setSocketOptionImpl(const
JNINativeInterface_ * * env=, _jobject * thisClz=, _jobject * aFileDescriptor=, int anOption=,
_jobject * aValue=)  Line 2321 + 0xc	C
> Java stack is:
> Stack Trace (003FB238):
>   [003FB238] 00000000(n): org/apache/harmony/luni/platform/OSNetworkSystem.setSocketOptionImpl(Ljava
> /io/FileDescriptor;ILjava/lang/Object;)V
>   [003FB238] 011D0625(m): org/apache/harmony/luni/platform/OSNetworkSystem.setSocketOption(Ljava/io/
> FileDescriptor;ILjava/lang/Object;)V
>   [003FB238] 011CFF4E(m): org/apache/harmony/luni/net/PlainDatagramSocketImpl.setOption(ILjava/lang/
> Object;)V
>   [003FB238] 011E3DB1(m): java/net/DatagramSocket.setReuseAddress(Z)V
>   [003FB238] 011E3BB0(m): tests/api/java/net/DatagramSocketTest.test_getReuseAddress()V
>   [003FB238] 100657D0(n): java/lang/reflect/VMReflection.invokeMethod(Ljava/lang/Object;Ljava/lang/O
> bject;[Ljava/lang/Object;)Ljava/lang/Object;
>   [003FB238] 011C2CA0(m): java/lang/reflect/Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljav
> a/lang/Object;
>   [003FB238] 011CCB25(m): junit/framework/TestCase.runTest()V
>   [003FB238] 011CC66E(m): junit/framework/TestCase.runBare()V
>   [003FB238] 011CC5BA(m): junit/framework/TestResult$1.protect()V
>   [003FB238] 011CC44F(m): junit/framework/TestResult.runProtected(Ljunit/framework/Test;Ljunit/frame
> work/Protectable;)V
>   [003FB238] 011CAA3C(m): junit/framework/TestResult.run(Ljunit/framework/TestCase;)V
>   [003FB238] 011CA910(m): junit/framework/TestCase.run(Ljunit/framework/TestResult;)V
>   [003FB238] 011CA85B(m): junit/framework/TestSuite.runTest(Ljunit/framework/Test;Ljunit/framework/T
> estResult;)V
>   [003FB238] 011CA12E(m): junit/framework/TestSuite.run(Ljunit/framework/TestResult;)V
>   [003FB238] 011C9B22(m): junit/textui/TestRunner.doRun(Ljunit/framework/Test;Z)Ljunit/framework/Tes
> tResult;
>   [003FB238] 011C4186(m): junit/textui/TestRunner.start([Ljava/lang/String;)Ljunit/framework/TestRes
> ult;
>   [003FB238] 011C365E(m): junit/textui/TestRunner.main([Ljava/lang/String;)V
>   [003FB238] 100657D0(n): java/lang/reflect/VMReflection.invokeMethod(Ljava/lang/Object;Ljava/lang/O
> bject;[Ljava/lang/Object;)Ljava/lang/Object;
>   [003FB238] 011C2CA0(m): java/lang/reflect/Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljav
> a/lang/Object;
>   [003FB238] 011A59DF(m): java/lang/VMStart$MainThread.runImpl()V
>   [003FB238] 100657D0(n): *null*
> End Stack Trace (003FB238, depth=22)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message