public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug java/35979] New: JNI method NewStringUTF crashes when passed a NULL pointer
@ 2008-04-19 12:07 thomas dot g dot girard at free dot fr
2008-04-19 20:52 ` [Bug libgcj/35979] " tromey at gcc dot gnu dot org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: thomas dot g dot girard at free dot fr @ 2008-04-19 12:07 UTC (permalink / raw)
To: gcc-bugs
Hello,
when running java-gnome 4 unit tests, I've found out that gij NewStringUTF
implementation crashes when its argument is NULL. Indeed in natString.cc the
very first line of _Jv_NewStringUTF(const char *bytes) calls strlen(bytes),
without checking whether bytes is NULL or not. Hence the crash.
Sun's implementation does not crash: it returns NULL instead.
However it seems gij implementation is correct according to
http://java.sun.com/docs/books/jni/html/functions.html#65644:
"Return Values. Returns a local reference to a string object, or NULL if the
string cannot be constructed. Returns NULL if and only if an invocation of this
function has thrown an exception."
Should gij implementation be changed to handle NULL? I've checked that the
crash should still occur on the trunk, r134466
--
Summary: JNI method NewStringUTF crashes when passed a NULL
pointer
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: java
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: thomas dot g dot girard at free dot fr
GCC build triplet: x86_64-unknown-linux-gnu
GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35979
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libgcj/35979] JNI method NewStringUTF crashes when passed a NULL pointer
2008-04-19 12:07 [Bug java/35979] New: JNI method NewStringUTF crashes when passed a NULL pointer thomas dot g dot girard at free dot fr
2008-04-19 20:52 ` [Bug libgcj/35979] " tromey at gcc dot gnu dot org
@ 2008-04-19 20:52 ` thomas dot g dot girard at free dot fr
2008-04-19 20:55 ` thomas dot g dot girard at free dot fr
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: thomas dot g dot girard at free dot fr @ 2008-04-19 20:52 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from thomas dot g dot girard at free dot fr 2008-04-19 20:51 -------
Created an attachment (id=15497)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15497&action=view)
testcase for NewStringUTF
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35979
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libgcj/35979] JNI method NewStringUTF crashes when passed a NULL pointer
2008-04-19 12:07 [Bug java/35979] New: JNI method NewStringUTF crashes when passed a NULL pointer thomas dot g dot girard at free dot fr
@ 2008-04-19 20:52 ` tromey at gcc dot gnu dot org
2008-04-19 20:52 ` thomas dot g dot girard at free dot fr
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: tromey at gcc dot gnu dot org @ 2008-04-19 20:52 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from tromey at gcc dot gnu dot org 2008-04-19 19:55 -------
>From your comment I assume that java-gnome is using the JNI NewStringUTF call.
This does not directly call _Jv_NewStringUTF. Instead, it calls
_Jv_JNI_NewStringUTF
(in jni.cc). That code wraps the call to _Jv_NewStringUTF in a
try...catch.
So, if this is crashing for you, something else is going wrong.
Ordinarily libgcj will turn the SEGV into a NullPointerException, which
should be handled by that try...catch.
If you have a minimal test case, I could take a look.
--
tromey at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35979
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libgcj/35979] JNI method NewStringUTF crashes when passed a NULL pointer
2008-04-19 12:07 [Bug java/35979] New: JNI method NewStringUTF crashes when passed a NULL pointer thomas dot g dot girard at free dot fr
2008-04-19 20:52 ` [Bug libgcj/35979] " tromey at gcc dot gnu dot org
2008-04-19 20:52 ` thomas dot g dot girard at free dot fr
@ 2008-04-19 20:55 ` thomas dot g dot girard at free dot fr
2008-04-19 21:17 ` [Bug libgcj/35979] JNI method NewStringUTF throws NPE " tromey at gcc dot gnu dot org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: thomas dot g dot girard at free dot fr @ 2008-04-19 20:55 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from thomas dot g dot girard at free dot fr 2008-04-19 20:54 -------
You are absolutely right, thanks for pointing this out. The SIGSEGV gets
converted to an NPE.
But Sun's implementation does not throw an NPE. Please have a look at the
attached testcase. You can launch it using 'make JAVA=/path/to/sun/vm' to use a
different VM.
Outputs: 'Got: null' with Sun's VM, and 'Got: java.lang.NullPointerException'
with gij.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35979
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libgcj/35979] JNI method NewStringUTF throws NPE when passed a NULL pointer
2008-04-19 12:07 [Bug java/35979] New: JNI method NewStringUTF crashes when passed a NULL pointer thomas dot g dot girard at free dot fr
` (2 preceding siblings ...)
2008-04-19 20:55 ` thomas dot g dot girard at free dot fr
@ 2008-04-19 21:17 ` tromey at gcc dot gnu dot org
2008-04-19 21:36 ` tromey at gcc dot gnu dot org
2008-04-19 21:36 ` tromey at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: tromey at gcc dot gnu dot org @ 2008-04-19 21:17 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from tromey at gcc dot gnu dot org 2008-04-19 21:16 -------
Testing a patch.
--
tromey at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |tromey at gcc dot gnu dot
|dot org |org
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2008-04-19 21:16:34
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35979
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libgcj/35979] JNI method NewStringUTF throws NPE when passed a NULL pointer
2008-04-19 12:07 [Bug java/35979] New: JNI method NewStringUTF crashes when passed a NULL pointer thomas dot g dot girard at free dot fr
` (4 preceding siblings ...)
2008-04-19 21:36 ` tromey at gcc dot gnu dot org
@ 2008-04-19 21:36 ` tromey at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: tromey at gcc dot gnu dot org @ 2008-04-19 21:36 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from tromey at gcc dot gnu dot org 2008-04-19 21:35 -------
Fix checked in.
--
tromey at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.4.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35979
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libgcj/35979] JNI method NewStringUTF throws NPE when passed a NULL pointer
2008-04-19 12:07 [Bug java/35979] New: JNI method NewStringUTF crashes when passed a NULL pointer thomas dot g dot girard at free dot fr
` (3 preceding siblings ...)
2008-04-19 21:17 ` [Bug libgcj/35979] JNI method NewStringUTF throws NPE " tromey at gcc dot gnu dot org
@ 2008-04-19 21:36 ` tromey at gcc dot gnu dot org
2008-04-19 21:36 ` tromey at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: tromey at gcc dot gnu dot org @ 2008-04-19 21:36 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from tromey at gcc dot gnu dot org 2008-04-19 21:35 -------
Subject: Bug 35979
Author: tromey
Date: Sat Apr 19 21:35:02 2008
New Revision: 134471
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134471
Log:
PR libgcj/35979:
* jni.cc (_Jv_JNI_NewStringUTF): Return NULL if bytes==NULL.
Modified:
trunk/libjava/ChangeLog
trunk/libjava/jni.cc
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35979
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-04-19 21:36 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-19 12:07 [Bug java/35979] New: JNI method NewStringUTF crashes when passed a NULL pointer thomas dot g dot girard at free dot fr
2008-04-19 20:52 ` [Bug libgcj/35979] " tromey at gcc dot gnu dot org
2008-04-19 20:52 ` thomas dot g dot girard at free dot fr
2008-04-19 20:55 ` thomas dot g dot girard at free dot fr
2008-04-19 21:17 ` [Bug libgcj/35979] JNI method NewStringUTF throws NPE " tromey at gcc dot gnu dot org
2008-04-19 21:36 ` tromey at gcc dot gnu dot org
2008-04-19 21:36 ` tromey at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).