Date: Mon, 21 Jun 2010 11:40:05 GMT From: Oliver Adler <bug_reporter@a999.de> To: freebsd-java@FreeBSD.org Subject: Re: java/147512: Crash of RXTX-2.1-7 on AMD64 system [PATCH] Message-ID: <201006211140.o5LBe5Qp030212@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR java/147512; it has been noted by GNATS. From: Oliver Adler <bug_reporter@a999.de> To: bug-followup@FreeBSD.org Cc: Subject: Re: java/147512: Crash of RXTX-2.1-7 on AMD64 system [PATCH] Date: Mon, 21 Jun 2010 13:17:00 +0200 --TB36FDmn/VVEgNH/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hello, meanwhile I know what the reason for problem is and have a patch available (see attachment). The problem is, that the routine get_java_var is used for retrieving the java JNI eis structure and assumes that all pointers are 32 Bit. That is not true for amd64. The attached fix adds a new function get_java_eis which uses correct types as return code and also uses GetObjectField from the JNI to get the event_info_struct. I tested the patch on both i386 and amd64 architectures. And on both architectures the patch compiles and the crash described in the "How to Repeat" section does not appear any more and the arduino Serial Console is working. Basically this error is in the original code of the RXTX-2.1-7 project team. I suppose the error should also be present on linux platforms. Probably the project team should be noticed of this problem and the according patch. Greetings Oliver On Sat, Jun 05, 2010 at 10:40:07PM +0000, FreeBSD-gnats-submit@FreeBSD.org wrote: > Thank you very much for your problem report. > It has the internal identification `java/147512'. > The individual assigned to look at your > report is: freebsd-java. > > You can access the state of your problem report at any time > via this link: > > http://www.freebsd.org/cgi/query-pr.cgi?pr=147512 > > >Category: java > >Responsible: freebsd-java > >Synopsis: Crash of RXTX-2.1-7 on AMD64 system > >Arrival-Date: Sat Jun 05 22:40:07 UTC 2010 -- Oliver Adler eMail : bug_reporter@a999.de --TB36FDmn/VVEgNH/ Content-Type: text/x-csrc; charset=us-ascii Content-Disposition: attachment; filename="patch-SerialImp.c" --- /usr/ports/comms/rxtx.orig/work/rxtx-2.1-7r2/src/SerialImp.c 2006-01-29 23:19:04.000000000 +0100 +++ /usr/ports/comms/rxtx/work/rxtx-2.1-7r2/src/SerialImp.c 2010-06-18 10:23:54.000000000 +0200 @@ -2906,6 +2906,40 @@ #endif /* !WIN32 */ /*---------------------------------------------------------- +get_java_eis + + accept: env (keyhole to java) + jobj (java RXTXPort object) + return: a pointer to the eis structure + exceptions: none + comments: +----------------------------------------------------------*/ +struct event_info_struct* get_java_eis( JNIEnv *env, jobject jobj, char *id, char *type ) +{ + struct event_info_struct * result = 0; + jclass jclazz = (*env)->GetObjectClass( env, jobj ); + jfieldID jfd = (*env)->GetFieldID( env, jclazz, id, type ); + +/* + ENTER( "get_java_eis" ); +*/ + if( !jfd ) { + (*env)->ExceptionDescribe( env ); + (*env)->ExceptionClear( env ); + (*env)->DeleteLocalRef( env, jclazz ); + LEAVE( "get_java_eis" ); + return result; + } + result = (struct event_info_struct*)((*env)->GetObjectField( env, jobj, jfd )); +/* ct7 & gel * Added DeleteLocalRef */ + (*env)->DeleteLocalRef( env, jclazz ); +/* + LEAVE( "get_java_eis" ); +*/ + return result; +} + +/*---------------------------------------------------------- read_byte_array accept: int fd file descriptor to read from @@ -2938,8 +2972,8 @@ fd_set rset; /* TRENT */ int flag, count = 0; - struct event_info_struct *eis = ( struct event_info_struct * ) - get_java_var( env, *jobj,"eis","J" ); + + struct event_info_struct *eis = get_java_eis( env, *jobj,"eis","J" ); report_time_start(); flag = eis->eventflags[SPE_DATA_AVAILABLE]; --TB36FDmn/VVEgNH/--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201006211140.o5LBe5Qp030212>