Hi!!
Even with putting lot of effort to find the reason for crash, I could
not find any :(
I could not even run it with valgrind because I could not make it
working for me on Android cupcake 1.5.
Here is the problem description again
I have a Java application (apk), on one of the button press I invoke
an init function which calls native init function using JNI. All init
functions are
int Init(void)
In the native init function - I create threads (using pthread) and
return, and each thread does some local initializations, these threads
communicate with each other using queues using POSIX (conditional
variables and mutex).
Native code never invokes VM.
I observe the crash when my JAVA init method returns after
successfully calling the native init function; I get the crash call
stack through ddms and doing grep with arm-eabi-nm gives me always a
different call stack but always in mynativelib.so. Sometimes I have
observed crash in malloc, __FILE__ also.
If I run a native application (NATIVE-APP) through adb shell on
Android and do dlopen to the same mynativelib.so, and call my native
init, it always work and never crashes. I could not crash my native
application after repeating same steps for a significant number (20)
of times with clean builds (4/5 times).
I have observed a funny behavior in my JAVA application, every third
time my application does not crash. I do use persistent object/memory
but all of them are readonly(I am not writing to them from my
program).
I tried using checkjni, but the behavior is same and I don't get any
additional information on ddms.
The size of mynativelib.so is 13M, is that a problem? I can see even
bigger .so in system/lib
My native code which runs in the context of multiple threads has lot
of static variables, could that be a problem? If so why it works
properly from NATIVE-APP all the time?I have observed the same thread
execution sequence on both the cases(native app and Java app).
I am creating threads in detached state with default 1MB stack size.
Can that be a problem?
Am I missing anything? Actually I just followed the development/
samples/PlatformLibrary. I have tested successfully my JAVA code
without native (JNI).
Any directions to solve the crash will be great help!!
Thanks
Ashutosh