On Feb 6, 2009, at 11:19, Aaron Lav <a...@pobox.com> wrote:

On Fri, Feb 06, 2009 at 11:07:24AM -0800, Andi Vajda wrote:

On Fri, 6 Feb 2009, Aaron Lav wrote:

Does it crash if you don't call initVM() ?

No, the call to _testjcc.initVM(...) seems to be required to
make it crash.

There are two pieces to initVM():
 - initVM() proper (defined in jcc.cpp)
 - initializing your classes

The initVM() that is called from Python is a function called
__initialize__() that is generated by JCC. It's defined in a file called
__init__.cpp. It first calls the actual initVM() and then calls the
__initialize__() on each top level package JCC generates wrappers for.

For example, PyLucene's __initialize__() looks like:

PyObject *__initialize__(PyObject *module, PyObject *args, PyObject *kwds)
{
   PyObject *env = initVM(module, args, kwds);

   if (env == NULL)
       return NULL;

   java::__initialize__(module);
   org::__initialize__(module);

   return env;
}

Does it still crash if you comment out the calls to
__initialize__(module) that the top level __initialize__() makes ?

Yes.  I commented out the lines
   #for name, entries in packages:
   #    line(out, indent + 1, '%s::__initialize__(module);', name)
from python.py, removed the build directory and rebuilt
(checking that the 'java::__initialize__' and
'org::__initialize__' calls were gone from __init__.cpp), and reran,
and it still faults.

Ok, so keeping these commented out, how much can you comment out of the actual initVM() defined in jcc.cpp until it no longer crashes ?

To make rebuilds fast, use shared
mode and just rebuild jcc so that you get a new libjcc.so (be sure to call install).

With non shared mode, you can edit the copy of jcc.cpp JCC copied into your extension's build tree and re-build with --install. Does turning --debug on have an effect on the crash ? (I expect that to also turn compiler optimizations off -O0)

Andi..



   Aaron (a...@pobox.com)

Reply via email to