Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2006

Tip: Looking for answers? Try searching our database.

Extremely strange crash problem in JNI

Thread view: 
outsiderjustice@gmail.com - 03 Apr 2006 20:37 GMT
Hi All,

This is a question to those Java/JNI/C++ experts, personally I think
the problem is very tough, so please answer it if you are an experts in
all three areas.

We have a Java application that can make calls to some C++ module
functions through JNI, this all works fine until we introduced
std::fstream in the C++ module, suddenly stack is corrupted in some C++
JNI call that cause the java application to generate random signals
(SIGBUS, SIGILL, SIGSEGV etc, this is on Solaris 8) and crash, the
strange part is that it would crash even if we don't create any actual
std::fstream object or execute any std::fstream related code at all at
runtime, the bare existence of a reference (declaration) of
std::fstream in the C++ module caused the problem, once I changed
std::fstream to use the standard stdio FILE stream, the crash problem
goes away. We don't have this problem on Windows.

We thought the problem might be caused by some namespace conflict
between java and the std::fstream in the C++ module, but we can not
prove it.

Now the questions to the experts:

1. Does java have problem if std::fstream is used in JNI C++ code?
2. Is there a possible name conflict?
3. What you think might be the problem here?

Thanks.

Yufeng
Gordon Beaton - 03 Apr 2006 21:03 GMT
> 1. Does java have problem if std::fstream is used in JNI C++ code?
> 2. Is there a possible name conflict?

No and no.

> 3. What you think might be the problem here?

Typical memory corruption error, possibly due to a stray pointer
(unitialized or null) or a bounds error (overwriting the bounds of an
array or struct).

These and other typical causes are described here (its a C FAQ but
most of it applies just as well to C++):

 http://www.eskimo.com/~scs/c-faq.com/strangeprob/funnybugs.html

/gordon

Signature

[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e

Gordon Beaton - 04 Apr 2006 08:25 GMT
> These and other typical causes are described here (its a C FAQ but
> most of it applies just as well to C++):
>
>   http://www.eskimo.com/~scs/c-faq.com/strangeprob/funnybugs.html

Hmm, I actually meant to post this link, but both (and others in the
same document) apply...

 http://www.eskimo.com/~scs/c-faq.com/strangeprob/segv.html

/gordon

Signature

[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e

outsiderjustice@gmail.com - 04 Apr 2006 17:24 GMT
Please note that this problem is not caused by any runtime code, as I
said, simply replace the std::fstream reference to a stdio FILE stream
solved the problem, even when there's no actual stream object is
created.

We have done extensive code analysis to eliminate all possible memory
corruptions, but that does not seem to be related with the actual
problem.

> > These and other typical causes are described here (its a C FAQ but
> > most of it applies just as well to C++):
[quoted text clipped - 11 lines]
> [  do not email me copies of your followups  ]
> g o r d o n + n e w s @  b a l d e r 1 3 . s e


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.