Ignore:
Timestamp:
2012-03-21T20:15:19+13:00 (12 years ago)
Author:
ak19
Message:

Recommitting previous commit with debugging code this time (debug output statements are nested within ifdefs on _DEBUG). Previous commit message: GS3 tomcat server crashes because java crashes owing to some error in the JNI code. The error may be related to pointers having been stored as int rather than long, an issue that's become noticeable on 64 bit linux machines. Changes have been made in the JNI code where these pointers that are transferred between Java and C++ code are stored (GetIntField and SetIntField to GetLongField and SetLongField, as well as declaration of data_ptr as jlong not jint). Committing code first without debug statements so the commits can easily be done separately.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/common-src/indexers/mgpp/jni/MGPPSearchWrapperImpl.cpp

    r25244 r25245  
    3535#include "GSDLQueryParser.h"
    3636#include "MGQuery.h"
     37
     38// turning on debugging
     39#define _DEBUG
    3740 
    3841MGPPSearchData::MGPPSearchData() {
     
    162165Java_org_greenstone_mgpp_MGPPSearchWrapper_initCppSide (JNIEnv *j_env, jobject j_obj){
    163166
     167#ifdef _DEBUG
     168  cerr << "**** JNI debugging for GS3. initCppSide: SetLongField()\n";
     169#endif
     170
    164171  MGPPSearchData * data = new MGPPSearchData();
     172
     173#ifdef _DEBUG
     174  fprintf (stderr, "1a. data before SetLongField() is: %ld and as hex: %lX\n", data, data);
     175  fprintf (stderr, "1b. FID_mgpp_data before SetLongField() is: %ld and as hex: %lX\n", FID_mgpp_data, FID_mgpp_data);
     176#endif
     177
    165178  j_env->SetLongField(j_obj, FID_mgpp_data, (long)data);
     179
     180#ifdef _DEBUG
     181  fprintf (stderr, "1a. data after SetLongField() is: %ld and as hex: %lX\n", data, data);
     182  fprintf (stderr, "1b. FID_mgpp_data after SetLongField() is: %ld and as hex: %lX\n", FID_mgpp_data, FID_mgpp_data);
     183#endif
    166184
    167185  return true;
     
    177195JNIEXPORT jboolean JNICALL
    178196Java_org_greenstone_mgpp_MGPPSearchWrapper_loadIndexData (JNIEnv *j_env, jobject j_obj,  jstring j_index_name) {
     197#ifdef _DEBUG
     198  fprintf (stderr, "in loadIndexData\n");
     199#endif
    179200
    180201  jlong data_ptr = j_env->GetLongField(j_obj, FID_mgpp_data);
     202
     203#ifdef _DEBUG
     204  fprintf (stderr, "1. data_ptr at start is: %ld and as hex: %lX\n", data_ptr, data_ptr);
     205#endif
     206
    181207  MGPPSearchData * data = (MGPPSearchData *)data_ptr;
    182208
     
    210236Java_org_greenstone_mgpp_MGPPSearchWrapper_unloadIndexData (JNIEnv *j_env, jobject j_obj) {
    211237
     238#ifdef _DEBUG
     239  fprintf (stderr, "in unloadIndexData\n");
     240#endif
     241
    212242  jlong data_ptr = j_env->GetLongField(j_obj, FID_mgpp_data);
     243
     244#ifdef _DEBUG
     245  fprintf (stderr, "1. data_ptr at start is: %ld and as hex: %lX\n", data_ptr, data_ptr);
     246#endif
     247
    213248  MGPPSearchData * data = (MGPPSearchData *)data_ptr;
    214249
     
    428463                            jobject j_obj,
    429464                            jstring j_level){
     465  // print to stderr start of setReturnLevel, print out FID..
     466  // %ld or %x -> need to print out pointer -
     467  // Later consider field containing unsignedlong instead of long
     468 
     469#ifdef _DEBUG
     470  cerr << "In MGPPSearchWrapperImpl.setReturnLevel()\n";
     471  fprintf (stderr, "1. FID_mgpp_data at start is: %ld and as hex: %lX\n", FID_mgpp_data, FID_mgpp_data);
     472#endif
    430473
    431474  jlong data_ptr = j_env->GetLongField(j_obj, FID_mgpp_data);
    432   MGPPSearchData * data = (MGPPSearchData *)j_env->GetLongField(j_obj, FID_mgpp_data);
    433 
    434 
     475
     476#ifdef _DEBUG
     477  fprintf (stderr, "1a. data_ptr at start is: %ld and as hex: %lX\n", data_ptr, data_ptr);
     478#endif
     479
     480  MGPPSearchData * data = (MGPPSearchData *)j_env->GetLongField(j_obj, FID_mgpp_data);
     481
     482#ifdef _DEBUG
     483  fprintf (stderr, "2a. FID_mgpp_data after data instantiation: %ld and as hex: %lX\n", FID_mgpp_data, FID_mgpp_data);
     484  fprintf (stderr, "2b. Pointer value of data upon inst: %ld and as hex: %lX\n", data, data);
     485#endif
     486
     487  // print out FID again.. as long decimal and as hex
     488  // %ld or %x -> need to print out pointer -
     489  // in the C code in the Setlong bit in this file
     490  // And the place on the java side, maybe in the configure
     491  //  org.greenstone.gsdl3.service.GS2MGPPSearch.configure(Lorg/w3c/dom/Element;Lorg/w3c/dom/Element;)Z+18
     492  // find out what value we're SETTING the value of the pointer to
    435493  const char * level = j_env->GetStringUTFChars(j_level, NULL);
    436494  if (level==NULL) {
    437495    return; // exception already thrown
    438496  }
     497
     498#ifdef _DEBUG
     499  fprintf (stderr, "3a. FID_mgpp_data after level: %ld and as hex: %lX\n", FID_mgpp_data, FID_mgpp_data);
     500  fprintf (stderr, "3b. Pointer value of data after level: %ld and as hex: %lX\n", data, data);
     501#endif
    439502 
    440503  data->level.clear();
     504
     505#ifdef _DEBUG
     506  fprintf (stderr, "4a. FID_mgpp_data after data->level.clear(): %ld and as hex: %lX\n", FID_mgpp_data, FID_mgpp_data);
     507  fprintf (stderr, "4b. Pointer value of data after level.clear(): %ld and as hex: %lX\n", data, data);
     508#endif
     509
    441510  SetCStr(data->level, level);
     511
     512#ifdef _DEBUG
     513  fprintf (stderr, "5a. FID_mgpp_data after SetCStr on data: %ld and as hex: %lX\n", FID_mgpp_data, FID_mgpp_data);
     514  fprintf (stderr, "5b. Pointer value of data after SetCStr: %ld and as hex: %lX\n", data, data);
     515#endif
    442516 
    443517  // release the java stuff
    444518  j_env->ReleaseStringUTFChars(j_level, level);
     519
     520#ifdef _DEBUG
     521  fprintf (stderr, "5a. FID_mgpp_data at end of setReturnLevel: %ld and as hex: %lX\n", FID_mgpp_data, FID_mgpp_data);
     522  fprintf (stderr, "5b. Pointer value of data at end of SetReturnLevel: %ld and as hex: %lX\n", data, data);
     523#endif
    445524
    446525}
Note: See TracChangeset for help on using the changeset viewer.