O
outsiderjustice
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
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