Everything related to SDK.
By d76
#369024
Hi,
what i want do is, read mxs, check for certain objects by name, append matching to new mxs and save.. simple, but always python crashes after i call getObjectNames(). If i am getting object by name, everything is fine, but in this case, i am not going to know the name before real processing..
any ideas? am i doing something wrong? thanks a lot.

environment is: Mac OS X 10.7.5, Python 3.2, pymaxwell 2.7.20..

code:
Code: Select all
#!/Library/Frameworks/Python.framework/Versions/3.2/bin/python3
# -*- coding: utf-8 -*-

from pymaxwell import *

def main():
    print(Cmaxwell.getEngineVersion())
    Mx = Cmaxwell(mwcallback)
    Mx.readMXS("test_object23.mxs")
    nms = Mx.getObjectNames()
    for n in nms:
        o = Mx.getObject(n)

main()
output:
Code: Select all
$ ./bug.py 
2.7.20.0
Python(21295,0x7fff77880960) malloc: *** error for object 0x101b04d40: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
crash log excerpt (for the lucky ones who know how to read it):
Code: Select all
Process:         Python [21028]
Path:            /Library/Frameworks/Python.framework/Versions/3.2/Resources/Python.app/Contents/MacOS/Python
Identifier:      Python
Version:         ??? (???)
Code Type:       X86-64 (Native)
Parent Process:  bash [20999]

Date/Time:       2013-07-02 18:54:11.605 +0200
OS Version:      Mac OS X 10.7.5 (11G63)
Report Version:  9

Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000

Application Specific Information:
objc[21028]: garbage collection is OFF
*** error for object 0x101124ac0: pointer being freed was not allocated
 

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	0x00007fff91ab0ce2 __pthread_kill + 10
1   libsystem_c.dylib             	0x00007fff8b53d7d2 pthread_kill + 95
2   libsystem_c.dylib             	0x00007fff8b52ea7a abort + 143
3   libsystem_c.dylib             	0x00007fff8b58d84c free + 389
4   _pymaxwell.so                 	0x00000001013247ab CobjectRenderBase::~CobjectRenderBase() + 363
5   _pymaxwell.so                 	0x00000001013258e0 CobjectRender::Cpointer::free() + 48
6   _pymaxwell.so                 	0x0000000101318b13 Cscene::freeObjects() + 99
7   _pymaxwell.so                 	0x0000000101316966 Cscene::free() + 342
8   _pymaxwell.so                 	0x0000000101316c1d Cscene::~Cscene() + 13
9   _pymaxwell.so                 	0x00000001012ebf12 Cmaxwell::~Cmaxwell() + 34
10  _pymaxwell.so                 	0x00000001012ebec9 Cmaxwell::~Cmaxwell() + 9
11  _pymaxwell.so                 	0x000000010120eff3 _wrap_delete_Cmaxwell + 301
12  org.python.python             	0x000000010000c828 PyObject_Call + 104
13  org.python.python             	0x000000010000e0b6 PyObject_CallFunctionObjArgs + 406
14  _pymaxwell.so                 	0x0000000101207a26 SwigPyObject_dealloc + 117
15  org.python.python             	0x000000010004c3fb dict_dealloc + 155
16  org.python.python             	0x00000001000617a5 subtype_dealloc + 949
17  org.python.python             	0x000000010003858d frame_dealloc + 109
18  org.python.python             	0x00000001000b4345 PyEval_EvalFrameEx + 29989
19  org.python.python             	0x00000001000b4ffa PyEval_EvalCodeEx + 1770
20  org.python.python             	0x00000001000b530f PyEval_EvalCode + 63
21  org.python.python             	0x00000001000dc6ab PyRun_FileExFlags + 187
22  org.python.python             	0x00000001000dc979 PyRun_SimpleFileExFlags + 521
23  org.python.python             	0x00000001000f1e65 Py_Main + 3237
24  org.python.python             	0x0000000100000e0b 0x100000000 + 3595
25  org.python.python             	0x0000000100000c94 0x100000000 + 3220
By Aji Enrico
#369033
If you remove def main
Code: Select all
from pymaxwell import *

scene = Cmaxwell(mwcallback)
scene.readMXS("c:/a/few.mxs")
print(scene.getObjectNames())
It will work once then crash on second run.

Think its a pointer issue.
User avatar
By Brany
#369044
It seems that method brokes scene objects names so python crashes when trying to free the scene. You can use this workaround instead:
Code: Select all
from pymaxwell import *

def getnames(scene):
	it = CmaxwellObjectIterator()
	obj = it.first(scene)
	list = []
	while not obj.isNull():
		name = obj.getName()
		list.append(name)
		obj = it.next()
	return list

#main
scene = Cmaxwell(mwcallback)
if scene.readMXS('C:/myscene.mxs'):
	print getnames(scene)
	print getnames(scene)
	print getnames(scene)
	print getnames(scene)
	print getnames(scene)
Hope it helps!
Last edited by Brany on Thu Jul 04, 2013 9:23 am, edited 1 time in total.
New podcast - CG Talks

Hi guys! We've just finished the first season of […]

Thanks, Luis, appreciated. It looks like industria[…]

That looks like a low bpc (bits per channel) norma[…]

Fully working plugin for C4D

When you will be working on it please try to keep […]