[Bf-python] Memory bug in Bpy api

Gilbert, Joseph T. jgilbert at tigr.ORG
Wed Jan 18 18:26:45 CET 2006


After installing and trying to run this (never could get cgkit to work
right so had to do some hacking). I did run into a crash when I ran the
script again:

Here's my stack trace into in the python24.dll

python24_d.dll!write4()  Line 937 + 0xf	C
python24_d.dll!_PyObject_DebugMalloc()  Line 1014 + 0xd	C
python24_d.dll!parsetok()  Line 146 + 0xc	C
python24_d.dll!PyParser_ParseStringFlagsFilename()  Line 56 + 0x19
C
python24_d.dll!PyParser_SimpleParseStringFlagsFilename()  Line 1387 +
0x1eC
python24_d.dll!Py_CompileStringFlags()  Line 1316 + 0x3a	C
python24_d.dll!Py_CompileString()  Line 1305 + 0x13	C
blender.exe!RunPython(Text * text=0x05af7f58, _object *
globaldict=0x05c4cab8)  Line 1519 + 0x1e	C
blender.exe!BPY_txt_do_python_Text(Text * text=0x05af7f58)  Line 552 +
0xdC
blender.exe!run_python_script(SpaceText * st=0x0aede8e0)  Line 1369 +
0x9C
blender.exe!winqreadtextspace(ScrArea * sa=0x0aede6a8, void *
spacedata=0x0aede8e0, BWinEvent * evt=0x0012fdf4)  Line 1506 + 0x9
C
blender.exe!scrarea_do_winhandle(ScrArea * area=0x0aede6a8, BWinEvent *
evt=0x0012fdf4)  Line 144 + 0x1a	C
blender.exe!scrarea_dispatch_events(ScrArea * sa=0x0aede6a8)  Line 564
+C
blender.exe!screen_dispatch_events()  Line 1150 + 0x9	C
blender.exe!screenmain()  Line 1404	C
blender.exe!main(int argc=1, char * * argv=0x05a13b10)  Line 594
C
blender.exe!mainCRTStartup()  Line 259 + 0x19	C
kernel32.dll!7c816d4f() 	
ntdll.dll!7c915b4f() 	
kernel32.dll!7c8399f3() 	 

in the python interal function parsetok() line 146 fails:
str = (char *) PyObject_MALLOC(len + 1);

PyObject_MALLOC fails to allocate 29 bites.  I have no idea why this is
the case. :) Maybe lack of memory? This is after RunPython tries to
compile the module's text again to execute.

Anyway that's all I can contribute :0 

________________________________________
From: bf-python-bounces at projects.blender.org
[mailto:bf-python-bounces at projects.blender.org] On Behalf Of Bobby
Parker
Sent: Tuesday, January 17, 2006 4:54 PM
To: bf-python at blender.org
Subject: [Bf-python] Memory bug in Bpy api

Hi,
I'm developing a script using the Python API, and I think I've found a
nice memory bug.

To best illuminate the error, I've provided a working copy of my script
at: http://www.stormwind-studios.com/Misc/ShaderEditorGUI.zip

Download this, create a subdirectory of bpymodules named "btor", and
unzip into that dir.

CgKit2(http://cgkit.sourceforge.net) and a renderman renderer (
http://www.aqsis.com, http://pixie.sourceforge.net ) are required.

Load the BtoR.py script in the btor package directory into the blender
text editor and hit alt+p

In the "Shader Path" enter a path (or browse) to a directory containing
renderman shader source files (*.sl). (for instance, on Debian, using
Aqsis, the shaders are at /usr/share/Aqsis/shaders/)

This should iterate the shaders on that path, and sort them into types.

The behaviour I've noticed is that on most first-time loads, the script
works fine. When selected different shaders and scrolling up and down
(with the mousewheel) shaders with large #'s of parameters will cause a
crash.

If the script doesn't crash the first time around, it almost always
crashes on the second invocation of the script (alt+p after escaping
out).

antont in #blendercoders was kind enough to test it in a debug build of
Blender, and recieved the following results:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1226287392 (LWP 27752)]
0xb7eac05e in PyObject_GC_UnTrack () from /usr/lib/libpython2.4.so.1.0
(gdb) bt


#0  0xb7eac05e in PyObject_GC_UnTrack () from
/usr/lib/libpython2.4.so.1.0
#1  0xb7e538fa in PyTuple_Pack () from /usr/lib/libpython2.4.so.1.0
#2  0xb7e80dfa in PyEval_EvalCode () from /usr/lib/libpython2.4.so.1.0


#3  0xb7e31f19 in PyFunction_SetClosure () from
/usr/lib/libpython2.4.so.1.0
#4  0xb7e4192d in PyDict_New () from /usr/lib/libpython2.4.so.1.0
#5  0xb7e41bf5 in PyDict_SetItem () from /usr/lib/libpython2.4.so.1.0


#6  0xb7e7fa36 in PyEval_EvalFrame () from /usr/lib/libpython2.4.so.1.0
#7  0xb7e80a2d in PyEval_EvalCodeEx () from /usr/lib/libpython2.4.so.1.0
#8  0xb7e80b76 in PyEval_EvalCode () from /usr/lib/libpython2.4.so.1.0


#9  0xb7e99525 in PyImport_ExecCodeModuleEx ()
   from /usr/lib/libpython2.4.so.1.0
#10 0xb7e998e9 in PyImport_ExecCodeModule () from
/usr/lib/libpython2.4.so.1.0
#11 0xb7e9b91e in PyImport_ReloadModule () from
/usr/lib/libpython2.4.so.1.0


#12 0x086041cc in blender_reload ()
#13 0xb7e44923 in PyCFunction_Call () from /usr/lib/libpython2.4.so.1.0
#14 0xb7e7ff37 in PyEval_EvalFrame () from /usr/lib/libpython2.4.so.1.0
#15 0xb7e80a2d in PyEval_EvalCodeEx () from /usr/lib/libpython2.4.so.1.0


#16 0xb7e80b76 in PyEval_EvalCode () from /usr/lib/libpython2.4.so.1.0
#17 0x08602d22 in RunPython ()
#18 0x08603bb4 in BPY_txt_do_python_Text ()
#19 0x0822aab5 in run_python_script ()
#20 0x0822b132 in winqreadtextspace ()


#21 0x081bd46a in scrarea_do_winhandle ()


Hope this helps! It's driving me UP THE WALL!

ShortWave in #blendercoders, #blender, #aqsis



More information about the Bf-python mailing list