I'm using osgIntrospection to build a Python wrapper in the same way that my friend Jose Luis use it to build osgLua.
But I have a Segmentation Fault when the createInstance method is called. I'm working with osg of the CVS.
The problem seems that is in osgIntrospection::variant_cast<float> ()
$ gdb python
(gdb) r
>>> import test
>>> test.test()
loading ... osg
--> Type Defined: 1
--> Value Defined: 1
Creating instance...
Program received signal SIGSEGV, Segmentation fault.
(gdb) bt
#0 0xb7eb7b8c in free () from /lib/tls/i686/cmov/libc.so.6
#1 0xb7eb983f in malloc () from /lib/tls/i686/cmov/libc.so.6
#2 0xb785b4b7 in operator new () from /usr/lib/libstdc++.so.6
#3 0xb7fd1956 in osgIntrospection::Value::Instance_box<float>::clone (this=0x8c5ced8) at /usr/local/include/osgIntrospection/Value:238
#4 0xb7937610 in osgIntrospection::Value::tryConvertTo () from /usr/local/lib/libosgIntrospection.so
#5 0xb7937c23 in osgIntrospection::Value::convertTo () from /usr/local/lib/libosgIntrospection.so
#6 0xb51ea122 in osgIntrospection::variant_cast<float> () from /usr/local/lib/osgPlugins/osgwrapper_osg.so
#7 0xb51ea12d in osgIntrospection::variant_cast<float> () from /usr/local/lib/osgPlugins/osgwrapper_osg.so
Someone can help me?
I attach a test.cpp file.
Cheers,
Miguel Escriva
// g++ -Wl,-E -fno-strict-aliasing -g -O2 -W -Wall -fPIC -I/usr/include/python2.4 -shared -losg -losgDB -losgIntrospection -o test.so test.cpp
// To reproduce the seg-fault:
//
// $ python
// Python 2.4.4c1 (#2, Oct 11 2006, 21:51:02)
// [GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)] on linux2
// Type "help", "copyright", "credits" or "license" for more information.
// >>> import test
// >>> test.test()
// loading ... osg
// --> Type Defined: 1
// --> Value Defined: 1
// Creating instance...
// Segmentation fault (core dumped)
// $
#include <iostream>
#include <osgIntrospection/Reflection>
#include <osgIntrospection/Type>
#include <osgDB/DynamicLibrary>
#include <osg/ref_ptr>
#include <Python.h>
// borrowed from osgDB...
std::string createLibraryNameForWrapper(const std::string& ext)
{
#if defined(WIN32)
// !! recheck evolving Cygwin DLL extension naming protocols !! NHV
#ifdef __CYGWIN__
return "cygosgwrapper_"+ext+".dll";
#elif defined(__MINGW32__)
return "libosgwrapper_"+ext+".dll";
#else
#ifdef _DEBUG
return "osgwrapper_"+ext+"d.dll";
#else
return "osgwrapper_"+ext+".dll";
#endif
#endif
#elif macintosh
return "osgwrapper_"+ext;
#elif defined(__hpux__)
// why don't we use PLUGIN_EXT from the makefiles here?
return "osgwrapper_"+ext+".sl";
#else
return "osgwrapper_"+ext+".so";
#endif
}
osgDB::DynamicLibrary *loadWrapper(const std::string &name)
{
std::cout << "loading ... " << name << std::endl;
return osgDB::DynamicLibrary::loadLibrary(
createLibraryNameForWrapper(name)
);
}
void test1_func()
{
osg::ref_ptr<osgDB::DynamicLibrary> osg_lib = loadWrapper("osg");
const osgIntrospection::Type &type = osgIntrospection::Reflection::getType("osg::Vec3");
std::cout << "--> Type Defined: " << type.isDefined() << std::endl;
osgIntrospection::ValueList vl;
osgIntrospection::Value v = osgIntrospection::Value(10.0f);
std::cout << "--> Value Defined: " << type.isDefined() << std::endl;
vl.push_back(v);
vl.push_back(v);
vl.push_back(v);
std::cout << "Creating instance..." << std::endl;
osgIntrospection::Value value = type.createInstance(vl);
std::cout << "Instance created OK!\n" << std::endl;
}
static PyObject * test_system(PyObject *self, PyObject *args)
{
test1_func();
return Py_BuildValue("");
}
static PyMethodDef TestMethods[] = {
{"test", test_system, METH_VARARGS, "osgIntrospection test."},
{NULL, NULL, 0, NULL}
};
PyMODINIT_FUNC inittest(void)
{
Py_InitModule("test", TestMethods);
}
_______________________________________________ osg-users mailing list [email protected] http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
