Comments (2)
Upon further investigation it seems that the problem is two fold.
First the code at [1] does not check the return value of FindClass
before using it in another function call at [2], which causes the segfault. Specifically, FindClass
will return 0
if it doesn't find the class and GetStaticFieldID
will segfault if the class is null.
As a Java developer, I would expect that if a class cannot be found then a ClassNotFoundException
will be thrown.
Second the code at [1] does not use the correct ClassLoader
. Quoting from [3], "FindClass locates the class loader associated with the current native method; that is, the class loader of the class that declared the native method." If " there is no current native method or its associated class loader [then] in that case, the result of ClassLoader.getSystemClassLoader is used." Looking at the back trace there is no Java frames that FindClass
can retrieve the ClassLoader
from, so it will use the system ClassLoader
, which does not contain the requested class.
As a Java developer, I would expect that if a class needs to be loaded to service a request then the ClassLoader
of the class making the request will be used, or the ClassLoader
of the callback.
As a Java developer, I expect the system ClassLoader
will never be used.
Finally, one more request. Please include debugging symbols in your releases. Then it will be much easier to find the bugs in the native code as I won't have to disassemble it first.
[1]
GMSEC_API/java/src_4x/gmsecJNI_Jenv.cpp
Line 358 in 660629d
[2]
GMSEC_API/java/src_4x/gmsecJNI_Jenv.cpp
Line 377 in 660629d
[3] https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html#FindClass
from gmsec_api.
Looking through the code a bit more, it seems that [4] has the right idea - to initialize all classes when the JNI interface is initialized. Then there will be Java frame on the stack, so FindClass
will use that ClassLoader
. It seems the call to FindClass
should be moved form Jenv
to Cache
. And any other calls to load GMSEC API Java classes should be done in Cache
as well so they are loaded when the JNI interface is initialized.
[4]
GMSEC_API/java/src_4x/gmsecJNI_Init.cpp
Line 39 in 660629d
from gmsec_api.
Related Issues (9)
- build error: cms/Connection.h: No such file or directory HOT 1
- activemq-cpp wrapper ignores sec-ssl-truststore unless sec-ssl-truststore-key is set HOT 1
- Deadlock publishing message HOT 2
- SIGSEGV in Message.getSubject() HOT 8
- Incorrect compilation of RHEL7,8 Support binaries.
- CVEs in GMSEC 4.9.1 Distribution HOT 1
- GMSEC 4.9.1 error on load HOT 3
- ConfigFile should support standard fields
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gmsec_api.