python - SIGSEGV: Segmentation Fault in JCC Library Code -


i'm using jcc python-java bridge , part works. however, i'm getting following error:

jre version: 7.0_17-b02

java vm: java hotspot(tm) client vm (23.7-b01 mixed mode linux-x86 )

problematic frame:

c [_ciasliveschema.so+0x21e75c] boxjobject(_typeobject*, _object*, java::lang::object*)+0x22c

the stack dump follows:

stack: [0xbfbe5000,0xbfc35000], sp=0xbfc33820, free space=314k

native frames: (j=compiled java code, j=interpreted, vv=vm code, c=native code)

c [_ciasliveschema.so+0x21e75c] boxjobject(_typeobject*, _object*, java::lang::object*)+0x22c

c [_ciasliveschema.so+0x221977] boxobject(_typeobject*, _object*, java::lang::object*)+0x27

c [_ciasliveschema.so+0x225149] _parseargs(_object*, unsigned int, char, ...)+0x2f69

c [_ciasliveschema.so+0x17e21c] schema::util::t_individualcaster_asmessage (schema::util::t_individualcaster*, _object*)+0xac

c [python+0x8bda4] pyeval_evalframeex+0x6494

c [python+0x8ccb1] pyeval_evalcodeex+0x871

c [python+0xe0a0c] fileno@@glibc_2.0+0xe0a0c

c [python+0x143b5] pyobject_call+0x45

c [python+0x1b107] fileno@@glibc_2.0+0x1b107

c [python+0x143b5] pyobject_call+0x45

c [python+0x84a72] pyeval_callobjectwithkeywords+0x42

c [python+0x1eec1] pyinstance_new+0x71

c [python+0x143b5] pyobject_call+0x45

c [python+0x86923] pyeval_evalframeex+0x1013

c [python+0x8b347] pyeval_evalframeex+0x5a37

c [python+0x8ccb1] pyeval_evalcodeex+0x871

c [python+0x8cd47] pyeval_evalcode+0x57

the code boxjobject function follows:

static int boxjobject(pytypeobject *type, pyobject *arg,                       java::lang::object *obj) {     if (arg == py_none)     {         if (obj != null)             *obj = object(null);     }     else if (pyobject_typecheck(arg, &py_type(object)))     {         if (type != null && !is_instance_of(arg, type))             return -1;          if (obj != null)             *obj = ((t_object *) arg)->object;     }     else if (pyobject_typecheck(arg, &py_type(finalizerproxy)))     {         arg = ((t_fp *) arg)->object;         if (pyobject_typecheck(arg, &py_type(object)))         {             if (type != null && !is_instance_of(arg, type))                     return -1;              if (obj != null)                 *obj = ((t_object *) arg)->object;         }         else             return -1;     }     else         return 1;      return 0; } 

this called in following manner:

int result = boxjobject(type, arg, obj); 

also, have modified following section of jcc.cpp:initvm() method:

    if (jni_createjavavm(&vm, (void **) &vm_env, &vm_args) < 0)     {         (unsigned int = 0; < noptions; i++)             delete vm_options[i].optionstring;           pyerr_format(pyexc_valueerror,                      "an error occurred while creating java vm");         return null;     } 

as follows:

    vm_args.noptions = noptions;     vm_args.ignoreunrecognized = jni_false;     vm_args.options = vm_options;      vminitsuccess = jni_createjavavm(&vm, (void **) &vm_env, &vm_args);     if (vminitsuccess < 0)     {         (unsigned int = 0; < noptions; i++)             delete vm_options[i].optionstring;          //set basic error message         sprintf(strvminitsuccess, "%d", vminitsuccess);         strcpy(strvmerror, "an error occurred while creating java vm (no exception): ");         strcat(strvmerror, strvminitsuccess);          //get exception if there 1         if((exc = vm_env->exceptionoccurred()))         {             //clear exception since have             vm_env->exceptionclear();             //get getmessage() method             if ((java_class = vm_env->findclass ("java/lang/throwable")))             {                 if ((method = vm_env->getmethodid(java_class, "getmessage", "()ljava/lang/string;")))                 {                     int size;                     strexc = static_cast<jstring>(vm_env->callobjectmethod(exc, method));                      charexc = vm_env->getstringutfchars(strexc, null);                     size = sizeof(strvmerror) + sizeof(charexc);                     char strvmexception[size];                     strcpy(strvmexception, "an error occurred while creating java vm (exception): ");                     strcat(strvmexception, charexc);                     pyerr_format(pyexc_valueerror, strvmexception);                     return null;                 }             }         }         pyerr_format(pyexc_valueerror, strvmerror);         return null;     } 

this attempt more detailed error message jcc when errors occur, possible source of error (although segfault error , stack trace above suggest otherwise).

finally, invoking initvm() method within python follows:

self.__cslschemalib = ciasliveschema.initvm(classpath=ciasliveschema.classpath) 

however, when attempt invoke method follows (to increase amount of memory available):

self.__cslschemalib = ciasliveschema.initvm(classpath=ciasliveschema.classpath, initialheap='512m', maxheap='2048m', maxstack='2048m', vmargs='-xcheck:jni,-verbose:jni,-verbose:gc') 

i following error:

jre version: 7.0_17-b02 java vm: java hotspot(tm) client vm (23.7-b01 mixed mode linux-x86 ) problematic frame: c 0x00000000

and stack trace:

stack: [0xbf6e0000,0xbf8e0000], sp=0xbf8dd580, free space=2037k

any suggestions?

the problem has been resolved. problem arose in call above boxjobject method:

if (boxobject(null, arg, obj) < 0) return -1; 

which _parseargs function in functions.cpp of jcc source code.

the problem arose because (at least quick scan of function), _parseargs checks see whether more args have been passed method accepts, not check case in fewer args have been passed.

in call individualcaster().asmessage() method in python code passing 1 argument when method takes two. while haven't located precise source of error in _parseargs method, have corrected call in python code takes correct number of args, , seg fault no longer occurring.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -