Link to home
Start Free TrialLog in
Avatar of jatinps
jatinps

asked on

JNI Problem - GetStringChars giving core dump after few repititve operation

jstring str;
char *value;

value = (char *) (*env)->GetStringUTFChars( env,str,NULL);
(*env)->ReleaseStringUTFChars(env,str,value);

Above piece of code gets executed for each field of an Java object. It gives a core dump after executing successfully for some field at one specefic point.

Re-arranging the position of the field also gives the error after certain number of execution.

I don't do anything with the value as well, just retrieve it and then release it. It still gives an error.


Any pointer?????????????
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Simply assigning finalValue to value just gives you two pointers to the SAME block of memory. Then in the next line you release this block of memory so finalValue is no longer pointing to a valid block of memory.
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vemul
vemul

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
- points to objects
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

vemul
Cleanup Volunteer
Finalized as proposed

modulo

Community Support Moderator
Experts Exchange