boost.python and Panda modules

So, I doubt anything’s going wrong with Boost, then, since Boost has no way to know anything about Panda’s reference-counting system.

Are you sure that you tested the code with the geom->ref() call inserted? Where is the crash?

David

I gave exact code that caused the crash few posts above, and

geom->ref();

line is included.

Crash happens as soon as I call segment.getGeom() in Python. This is complete command line session:

>> import segment
>> segment.getGeom()

CRASH

I mean, what is the C++ stack trace?

>	segment.pyd!getGeom()  Line 116 + 0x5a bytes	C++
 	segment.pyd!boost::python::objects::caller_py_function_impl<boost::python::detail::caller<_object * (__cdecl*)(void),boost::python::default_call_policies,boost::mpl::vector1<_object *> > >::operator()(_object * args, _object * kw)  Line 38 + 0x11 bytes	C++
 	segment.pyd!boost::python::objects::function::call()  + 0x273 bytes	C++
 	segment.pyd!boost::detail::function::void_function_ref_invoker0<boost::python::objects::`anonymous namespace'::bind_return,void>::invoke()  + 0x17 bytes	C++
 	segment.pyd!boost::python::handle_exception_impl()  + 0x100 bytes	C++
 	segment.pyd!boost::detail::function::void_function_ref_invoker0<boost::python::objects::`anonymous namespace'::bind_return,void>::invoke()  + 0x77 bytes	C++

And bunch of dlls.

Is that all of the stack? It’s hard to tell what’s going on in there.

Could the problem be the fact that you return (PyObject *)-1 in the failure case? That’s a weird thing to return. I believe the Python convention is for functions that return a pointer to return NULL on failure.

David

OK here’s everything that shows up in Call Stack window in MSVS once I choose to debug Python after crash:

 	msvcr90.dll!62b4ac08() 	
 	[Frames below may be incorrect and/or missing, no symbols loaded for msvcr90.dll]	
 	msvcr90.dll!62b46695() 	
 	msvcp90.dll!63794f2a() 	
 	msvcp90.dll!6379522b() 	
 	msvcp90.dll!637959be() 	
 	msvcp90.dll!63796396() 	
 	msvcp90.dll!63797296() 	
 	libpanda.dll!033631f9() 	
 	libpanda.dll!0336d412() 	
 	libpanda.dll!0337ec63() 	
>	segment.pyd!getGeom()  Line 116 + 0x5a bytes	C++
 	segment.pyd!boost::python::objects::caller_py_function_impl<boost::python::detail::caller<_object * (__cdecl*)(void),boost::python::default_call_policies,boost::mpl::vector1<_object *> > >::operator()(_object * args, _object * kw)  Line 38 + 0x11 bytes	C++
 	segment.pyd!boost::python::objects::function::call()  + 0x273 bytes	C++
 	segment.pyd!boost::detail::function::void_function_ref_invoker0<boost::python::objects::`anonymous namespace'::bind_return,void>::invoke()  + 0x17 bytes	C++
 	segment.pyd!boost::python::handle_exception_impl()  + 0x100 bytes	C++
 	segment.pyd!boost::detail::function::void_function_ref_invoker0<boost::python::objects::`anonymous namespace'::bind_return,void>::invoke()  + 0x77 bytes	C++
 	python26.dll!1e00f78e() 	
 	python26.dll!1e0130bf() 	
 	python26.dll!1e01563f() 	
 	python26.dll!1e015d17() 	
 	python26.dll!1e014f07() 	
 	python26.dll!1e0260dd() 	
 	python26.dll!1e04c7d0() 	
 	python26.dll!1e017f0c() 	
 	python26.dll!1e014f07() 	
 	python26.dll!1e015372() 	
 	python26.dll!1e015d17() 	
 	python26.dll!1e0156ef() 	
 	python26.dll!1e015d17() 	
 	python26.dll!1e014f07() 	
 	python26.dll!1e015372() 	
 	python26.dll!1e015d17() 	
 	python26.dll!1e01570b() 	
 	python26.dll!1e015d17() 	
 	python26.dll!1e014f07() 	
 	python26.dll!1e014f23() 	
 	python26.dll!1e013d18() 	
 	python26.dll!1e02011e() 	
 	python26.dll!1e014f23() 	
 	msvcr90.dll!62b73a58() 	
 	msvcr90.dll!62b760b7() 	
 	python26.dll!1e012ee3() 	
 	python26.dll!1e0a19d1() 	
 	tdbgtracer26.pyd!023431e3() 	
 	tdbgtracer26.pyd!02348c70() 	
 	tdbgtracer26.pyd!02348dde() 	
 	tdbgtracer26.pyd!0234955f() 	
 	python26.dll!1e05bd6c() 	
 	python26.dll!1e06804a() 	
 	python26.dll!1e052e72() 	
 	python26.dll!1e031622() 	
 	python26.dll!1e03368f() 	
 	python26.dll!1e03364e() 	
 	msvcr90.dll!62b32201() 	
 	python.exe!1d001160() 	
 	kernel32.dll!766d3677() 	
 	ntdll.dll!77559d72() 	
 	ntdll.dll!77559d45() 	

mscvcr90.dll is stack frame, while getGeom is function at the bottom of stack (I hope I got the terminology right)

I have changed -1 to NULL

Right, looks like it didn’t find the pdb’s for libpanda.dll, so there’s no useful debug information in the Panda part of the stack, which is what I really wanted to see.

Are you building your own Panda, or are you using the one provided here? I don’t think the ones provided here have pdb’s (they’re huge), so I guess you would have to build and use your own version of Panda to have them. Is this an option for you?

David

Yes, I forgot to mention that. I didn’t build Panda or Python myself so I only have release version of binaries. I guess I’ll have to build debug versions of both Python and Panda. I’ll do that tomorrow.

You don’t necessarily need a “debug” build in order to have pdb files. MSVC will give you pdb files even for a release build, and that would be perfectly useful here.

David

Forget it. I have VS 2010 on this machine and I don’t have the willpower to install VS Express and needed SDKs. VS 2010 won’t compile solution provided in makepanda, and doing makepanda\makepanda --everything reports that thirdparty folder isn’t there although it is there.

I can’t deal with this anymore.

Thanks for your time.

I was eliminating line by line from the function and I have discovered that as soon as I declare GeomVertexData

PT(GeomVertexData) vdata = new GeomVertexData("vertices", GeomVertexFormat::get_v3c4(), Geom::UH_static);

Thing blows up.

I have no problem declaring GeomTristrips the same way but for some reason GeomVertexData causes problems.

Well, I’ve tried on friend’s computer with VS2008 and it is working well. Apparently there are some problems with VS2010.

I’ve wasted your time for nothing.

Though if its of any consolation we now know what happens when you use VS2010.

BTW, Panda applications built in VS2010 also crash on startup.

That’s not really surprising, actually. In general, the different versions of MSVS are not cross-compatible, especially for C++ code. You have to compile all of a project using the same version of the compiler.

Since the Panda libraries distributed here are compiled via MSVS2008, it follows that you must also use MSVS2008 to compile your application, unless you compile your own version of Panda.

David