classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: Remove (bogus) asserts in java-net.


From: Mark Wielaard
Subject: [cp-patches] FYI: Remove (bogus) asserts in java-net.
Date: Thu, 12 Jan 2006 10:36:18 +0100

Hi,

The crashes we were seeing with the net code in Mauve were caused by the
following bogus asserts in VMPlainDatagramSocketImpl_nativeReceive():

  assert((*env)->GetArrayLength(env, receivedFromAddress) > 4);
  assert((*env)->GetArrayLength(env, receivedFromPort   ) > 1);
  assert((*env)->GetArrayLength(env, receivedLength     ) > 1);

Removing these makes most net tests work again. I am working on the
others. I also took the oppertunity to remove all other asserts() in
this code since they don't really add anything. Checking whether the
JNIEnv is not NULL isn't really that much help since if that is the case
lots of things will just break since it means the runtime is completely
broken.

2006-01-12  Mark Wielaard  <address@hidden>

    * native/jni/java-net/gnu_java_net_VMPlainDatagramSocketImpl.c:
    Remove asserts.
    * native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c: Likewise.
    * native/jni/java-net/java_net_VMInetAddress.c: Likewise.
    * native/jni/java-net/java_net_VMNetworkInterface.c: Likewise.
    * native/jni/java-net/javanet.c: Likewise.

Committed,

Mark
Index: native/jni/java-net/gnu_java_net_VMPlainDatagramSocketImpl.c
===================================================================
RCS file: 
/cvsroot/classpath/classpath/native/jni/java-net/gnu_java_net_VMPlainDatagramSocketImpl.c,v
retrieving revision 1.3
diff -u -r1.3 gnu_java_net_VMPlainDatagramSocketImpl.c
--- native/jni/java-net/gnu_java_net_VMPlainDatagramSocketImpl.c        9 Jan 
2006 21:30:15 -0000       1.3
+++ native/jni/java-net/gnu_java_net_VMPlainDatagramSocketImpl.c        12 Jan 
2006 09:28:25 -0000
@@ -1,5 +1,5 @@
 /* VMPlainDatagramSocketImpl.c - Native methods for PlainDatagramSocketImpl
-   Copyright (C) 2005 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -41,7 +41,6 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <assert.h>
 
 #include <jni.h>
 #include <jcl.h>
@@ -72,8 +71,6 @@
                                                   jclass klass __attribute__ 
((__unused__))
                                                   , jobject obj)
 {
-  assert(env!=NULL);
-  assert((*env)!=NULL);
 
 #ifndef WITHOUT_NETWORK
   _javanet_create(env, obj, 0);
@@ -91,8 +88,6 @@
                                                  jclass klass __attribute__ 
((__unused__)),
                                                  jobject obj)
 {
-  assert(env!=NULL);
-  assert((*env)!=NULL);
 
 #ifndef WITHOUT_NETWORK
   _javanet_close(env, obj, 0);
@@ -112,8 +107,6 @@
                                                    jobject addr, jint port)
 {
 #ifndef WITHOUT_NETWORK
-  assert(env!=NULL);
-  assert((*env)!=NULL);
 
   _javanet_connect(env, obj, addr, port, 0);
 #else /* not WITHOUT_NETWORK */
@@ -133,8 +126,6 @@
                                                 jobject obj,
                                                 jint port, jobject addr)
 {
-  assert(env!=NULL);
-  assert((*env)!=NULL);
 
 #ifndef WITHOUT_NETWORK
   _javanet_bind(env, obj, addr, port, 0);
@@ -154,8 +145,6 @@
                                                      jint option_id,
                                                      jobject val)
 {
-  assert(env!=NULL);
-  assert((*env)!=NULL);
 
 #ifndef WITHOUT_NETWORK
   _javanet_set_option(env, obj, option_id, val);
@@ -174,8 +163,6 @@
                                                      jobject obj, 
                                                      jint option_id)
 {
-  assert(env!=NULL);
-  assert((*env)!=NULL);
 
 #ifndef WITHOUT_NETWORK
   return(_javanet_get_option(env, obj, option_id));
@@ -204,12 +191,6 @@
   int           addr, *port, *bytes_read;
   char          *addressBytes;
 
-  assert(env!=NULL);
-  assert((*env)!=NULL);
-  assert((*env)->GetArrayLength(env, receivedFromAddress) > 4);
-  assert((*env)->GetArrayLength(env, receivedFromPort   ) > 1);
-  assert((*env)->GetArrayLength(env, receivedLength     ) > 1);
-
   addr = 0;
     
   port = (int*)(*env)->GetIntArrayElements(env, receivedFromPort, NULL);
@@ -281,9 +262,6 @@
 #ifndef WITHOUT_NETWORK
   jint netAddress;
 
-  assert(env!=NULL);
-  assert((*env)!=NULL);
-
   /* check if address given, tr 7.3.2005 */
   if (addr != NULL)
     {
@@ -327,9 +305,6 @@
   int  fd;
   int  result;
 
-  assert(env!=NULL);
-  assert((*env)!=NULL);
-
   /* check if address given, tr 7.3.2005 */
   if (addr != NULL)
     {
@@ -383,9 +358,6 @@
   int  fd;
   int  result;
 
-  assert(env!=NULL);
-  assert((*env)!=NULL);
-
   /* check if address given, tr 7.3.2005 */
   if (addr != NULL)
     {
Index: native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c
===================================================================
RCS file: 
/cvsroot/classpath/classpath/native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c,v
retrieving revision 1.3
diff -u -r1.3 gnu_java_net_VMPlainSocketImpl.c
--- native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c        9 Jan 2006 
21:30:15 -0000       1.3
+++ native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c        12 Jan 2006 
09:28:25 -0000
@@ -1,5 +1,5 @@
 /* VMPlainSocketImpl.c - Native methods for PlainSocketImpl class
-   Copyright (C) 2005 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -41,7 +41,6 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <assert.h>
  
 #include <jni.h>
 #include <jcl.h>
@@ -73,9 +72,6 @@
                                           jobject obj)
 {
 #ifndef WITHOUT_NETWORK
-  assert(env!=NULL);
-  assert((*env)!=NULL);
-
   _javanet_create(env, obj, JNI_TRUE);
 #else /* not WITHOUT_NETWORK */
 #endif /* not WITHOUT_NETWORK */
@@ -93,9 +89,6 @@
                                          jobject obj)
 {
 #ifndef WITHOUT_NETWORK
-  assert(env!=NULL);
-  assert((*env)!=NULL);
-
   _javanet_close(env, obj, 1);
 #else /* not WITHOUT_NETWORK */
 #endif /* not WITHOUT_NETWORK */
@@ -113,9 +106,6 @@
                                            jobject addr, jint port)
 {
 #ifndef WITHOUT_NETWORK
-  assert(env!=NULL);
-  assert((*env)!=NULL);
-
   _javanet_connect(env, obj, addr, port, 1);
 #else /* not WITHOUT_NETWORK */
 #endif /* not WITHOUT_NETWORK */
@@ -135,9 +125,6 @@
                                         jint port)
 {
 #ifndef WITHOUT_NETWORK
-  assert(env!=NULL);
-  assert((*env)!=NULL);
-
   _javanet_bind(env, obj, addr, port, 1);
 #else /* not WITHOUT_NETWORK */
 #endif /* not WITHOUT_NETWORK */
@@ -155,9 +142,6 @@
                                           jobject obj, jint queuelen)
 {
 #ifndef WITHOUT_NETWORK
-  assert(env!=NULL);
-  assert((*env)!=NULL);
-
   _javanet_listen(env, obj, queuelen);
 #else /* not WITHOUT_NETWORK */
 #endif /* not WITHOUT_NETWORK */
@@ -175,9 +159,6 @@
                                           jobject obj, jobject impl)
 {
 #ifndef WITHOUT_NETWORK
-  assert(env!=NULL);
-  assert((*env)!=NULL);
-
   _javanet_accept(env, obj, impl);
 #else /* not WITHOUT_NETWORK */
 #endif /* not WITHOUT_NETWORK */
@@ -197,9 +178,6 @@
   int      bytesAvailable;
   int      result;
   
-  assert(env!=NULL);
-  assert((*env)!=NULL);
-
   cls = (*env)->GetObjectClass(env, obj);
   if (cls == 0)
     {
@@ -241,9 +219,6 @@
                                              jint option_id, jobject val)
 {
 #ifndef WITHOUT_NETWORK
-  assert(env!=NULL);
-  assert((*env)!=NULL);
-
   _javanet_set_option(env, obj, option_id, val);
 #else /* not WITHOUT_NETWORK */
 #endif /* not WITHOUT_NETWORK */
@@ -261,9 +236,6 @@
                                              jint option_id)
 {
 #ifndef WITHOUT_NETWORK
-  assert(env!=NULL);
-  assert((*env)!=NULL);
-
   return(_javanet_get_option(env, obj, option_id));
 #else /* not WITHOUT_NETWORK */
   return NULL;
@@ -282,9 +254,6 @@
                                         jint offset, jint len)
 {
 #ifndef WITHOUT_NETWORK
-  assert(env!=NULL);
-  assert((*env)!=NULL);
-
   return(_javanet_recvfrom(env, obj, buf, offset, len, 0, 0));
 #else /* not WITHOUT_NETWORK */
   return 0;
@@ -303,9 +272,6 @@
                                          jint offset, jint len)
 {
 #ifndef WITHOUT_NETWORK
-  assert(env!=NULL);
-  assert((*env)!=NULL);
-
   _javanet_sendto(env, obj, buf, offset, len, 0, 0);
 #else /* not WITHOUT_NETWORK */
 #endif /* not WITHOUT_NETWORK */
@@ -317,9 +283,6 @@
                                                   jobject this)
 {
 #ifndef WITHOUT_NETWORK
-  assert (env != NULL);
-  assert ((*env) != NULL);
-
   _javanet_shutdownInput (env, this);
 #else /* not WITHOUT_NETWORK */
 #endif /* not WITHOUT_NETWORK */
@@ -331,9 +294,6 @@
                                                    jobject this)
 {
 #ifndef WITHOUT_NETWORK
-  assert (env != NULL);
-  assert ((*env) != NULL);
-
   _javanet_shutdownOutput (env, this);
 #else /* not WITHOUT_NETWORK */
 #endif /* not WITHOUT_NETWORK */
Index: native/jni/java-net/java_net_VMInetAddress.c
===================================================================
RCS file: 
/cvsroot/classpath/classpath/native/jni/java-net/java_net_VMInetAddress.c,v
retrieving revision 1.3
diff -u -r1.3 java_net_VMInetAddress.c
--- native/jni/java-net/java_net_VMInetAddress.c        19 Sep 2005 10:37:56 
-0000      1.3
+++ native/jni/java-net/java_net_VMInetAddress.c        12 Jan 2006 09:28:25 
-0000
@@ -1,5 +1,5 @@
 /* VMInetAddress.c - Native methods for InetAddress class
-   Copyright (C) 1998, 2002, 2005  Free Software Foundation, Inc.
+   Copyright (C) 1998, 2002, 2005, 2006  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -41,7 +41,6 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <assert.h>
 
 #include <jni.h>
 #include <jcl.h>
@@ -69,9 +68,6 @@
   int result;
   jstring retval;
 
-  assert (env != NULL);
-  assert ((*env) != NULL);
-
 #ifndef WITHOUT_NETWORK
   TARGET_NATIVE_NETWORK_GET_HOSTNAME (hostname, sizeof (hostname), result);
   if (result != TARGET_NATIVE_OK)
@@ -100,9 +96,6 @@
   jarray IParray;
   jbyte *octets;
 
-  assert (env != NULL);
-  assert ((*env) != NULL);
-
   /* Allocate an array for the IP address */
   IParray = (*env)->NewByteArray (env, 4);
   if (IParray == NULL)
@@ -150,9 +143,6 @@
   int result;
   jstring retval;
 
-  assert (env != NULL);
-  assert ((*env) != NULL);
-
   /* Grab the byte[] array with the IP out of the input data */
   len = (*env)->GetArrayLength (env, arr);
   if (len != 4)
@@ -215,9 +205,6 @@
   jarray ret_octets;
   int max_addresses;
 
-  assert (env != NULL);
-  assert ((*env) != NULL);
-
   /* Grab the hostname string */
   hostname = (*env)->GetStringUTFChars (env, host, 0);
   if (!hostname)
Index: native/jni/java-net/java_net_VMNetworkInterface.c
===================================================================
RCS file: 
/cvsroot/classpath/classpath/native/jni/java-net/java_net_VMNetworkInterface.c,v
retrieving revision 1.2
diff -u -r1.2 java_net_VMNetworkInterface.c
--- native/jni/java-net/java_net_VMNetworkInterface.c   2 Jul 2005 20:32:55 
-0000       1.2
+++ native/jni/java-net/java_net_VMNetworkInterface.c   12 Jan 2006 09:28:25 
-0000
@@ -1,5 +1,5 @@
 /* VMNetworkInterface.c - Native methods for NetworkInterface class
-   Copyright (C) 2003, 2005  Free Software Foundation, Inc.
+   Copyright (C) 2003, 2005, 2006  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -41,7 +41,6 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <assert.h>
 
 #include <jni.h>
 #include <jcl.h>
Index: native/jni/java-net/javanet.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/java-net/javanet.c,v
retrieving revision 1.27
diff -u -r1.27 javanet.c
--- native/jni/java-net/javanet.c       10 Jan 2006 12:23:27 -0000      1.27
+++ native/jni/java-net/javanet.c       12 Jan 2006 09:28:25 -0000
@@ -1,5 +1,5 @@
 /* javanet.c - Common internal functions for the java.net package
-   Copyright (C) 1998, 2002, 2004, 2005  Free Software Foundation, Inc.
+   Copyright (C) 1998, 2002, 2004, 2005, 2006  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -41,7 +41,6 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <assert.h>
 
 #include <jni.h>
 #include <jcl.h>
@@ -77,9 +76,6 @@
   jclass cls;
   jfieldID fid;
 
-  assert (env != NULL);
-  assert ((*env) != NULL);
-
   cls = (*env)->FindClass (env, class);
   if (cls == NULL)
     return;
@@ -106,9 +102,6 @@
   jfieldID fid;
   int fd;
 
-  assert (env != NULL);
-  assert ((*env) != NULL);
-
   DBG ("_javanet_get_int_field(): Entered _javanet_get_int_field\n");
 
   cls = (*env)->GetObjectClass (env, obj);
@@ -140,9 +133,6 @@
   jmethodID mid;
   jobject fd_obj;
 
-  assert (env != NULL);
-  assert ((*env) != NULL);
-
   DBG ("_javanet_create_localfd(): Entered _javanet_create_localfd\n");
 
   /* Look up the fd field */
@@ -197,9 +187,6 @@
   jmethodID mid;
   jobject obj;
 
-  assert (env != NULL);
-  assert ((*env) != NULL);
-
   cls = (*env)->FindClass (env, "java/lang/Boolean");
   if (cls == NULL)
     return NULL;
@@ -227,9 +214,6 @@
   jmethodID mid;
   jobject obj;
 
-  assert (env != NULL);
-  assert ((*env) != NULL);
-
   cls = (*env)->FindClass (env, "java/lang/Integer");
   if (cls == NULL)
     return NULL;
@@ -261,9 +245,6 @@
   jstring ip_str;
   jobject ia;
 
-  assert (env != NULL);
-  assert ((*env) != NULL);
-
   /* Build a string IP address */
   TARGET_NATIVE_NETWORK_INT_TO_IPADDRESS_BYTES (netaddr,
                                                octets[0],
@@ -318,9 +299,6 @@
   jclass this_cls;
   jfieldID fid;
 
-  assert (env != NULL);
-  assert ((*env) != NULL);
-
   /* Set the variable in the object */
   this_cls = (*env)->FindClass (env, "java/net/SocketImpl");
   if (this_cls == NULL)
@@ -346,9 +324,6 @@
 {
   jobject ia;
 
-  assert (env != NULL);
-  assert ((*env) != NULL);
-
   DBG ("_javanet_set_remhost(): Entered _javanet_set_remhost\n");
 
   /* Get an InetAddress object */
@@ -375,9 +350,6 @@
   jbyte *octets;
   int netaddr, len;
 
-  assert (env != NULL);
-  assert ((*env) != NULL);
-
   DBG ("_javanet_get_netaddr(): Entered _javanet_get_netaddr\n");
 
   if (addr == NULL)
@@ -444,9 +416,6 @@
   int fd;
   int result;
 
-  assert (env != NULL);
-  assert ((*env) != NULL);
-
   if (stream)
     {
       /* create a stream socket */
@@ -517,9 +486,6 @@
   int result;
   int error = 0;
 
-  assert (env != NULL);
-  assert ((*env) != NULL);
-
   fd = _javanet_get_int_field (env, this, "native_fd");
   if (fd == -1)
     return;
@@ -564,9 +530,6 @@
   int local_address, local_port;
   int remote_address, remote_port;
 
-  assert (env != NULL);
-  assert ((*env) != NULL);
-
   DBG ("_javanet_connect(): Entered _javanet_connect\n");
 
   /* Pre-process input variables */
@@ -707,9 +670,6 @@
   int result;
   int local_address, local_port;
 
-  assert (env != NULL);
-  assert ((*env) != NULL);
-
   DBG ("_javanet_bind(): Entering native bind()\n");
 
   /* Get the address to connect to */
@@ -811,9 +771,6 @@
   int fd;
   int result;
 
-  assert (env != NULL);
-  assert ((*env) != NULL);
-
   /* Get the real file descriptor */
   fd = _javanet_get_int_field (env, this, "native_fd");
   if (fd == -1)
@@ -850,9 +807,6 @@
   int local_address, local_port;
   int remote_address, remote_port;
 
-  assert (env != NULL);
-  assert ((*env) != NULL);
-
   /* Get the real file descriptor */
   fd = _javanet_get_int_field (env, this, "native_fd");
   if (fd == -1)
@@ -985,9 +939,6 @@
   int from_address, from_port;
   int received_bytes;
 
-  assert (env != NULL);
-  assert ((*env) != NULL);
-
   DBG ("_javanet_recvfrom(): Entered _javanet_recvfrom\n");
 
   /* Get the real file descriptor */
@@ -1079,9 +1030,6 @@
   jbyte *p;
   int bytes_sent;
 
-  assert (env != NULL);
-  assert ((*env) != NULL);
-
   /* Get the real file descriptor */
   fd = _javanet_get_int_field (env, this, "native_fd");
   if (fd == -1)
@@ -1152,9 +1100,6 @@
   int address;
   int result;
 
-  assert (env != NULL);
-  assert ((*env) != NULL);
-
   /* Get the real file descriptor */
   fd = _javanet_get_int_field (env, this, "native_fd");
   if (fd == -1)
@@ -1369,9 +1314,6 @@
   int address;
   int result;
 
-  assert (env != NULL);
-  assert ((*env) != NULL);
-
   /* Get the real file descriptor */
   fd = _javanet_get_int_field (env, this, "native_fd");
   if (fd == -1)
@@ -1545,9 +1487,6 @@
 {
   int fd;
 
-  assert (env != NULL);
-  assert ((*env) != NULL);
-
   /* Get the real file descriptor. */
   fd = _javanet_get_int_field (env, this, "native_fd");
   if (fd == -1)
@@ -1571,9 +1510,6 @@
 {
   int fd;
 
-  assert (env != NULL);
-  assert ((*env) != NULL);
-
   /* Get the real file descriptor. */
   fd = _javanet_get_int_field (env, this, "native_fd");
   if (fd == -1)

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]