[Bf-python] Reason for removal of ReleaseGlobalDictionary in BPY_interface.c

ChrisKeith at aol.com ChrisKeith at aol.com
Mon Feb 16 17:58:28 CET 2004


Hello Willian -

I realized that you may want an explanation for why I removed the 
"ReleaseGlobalDictionary" line of code, as shown in this partial diff:

Index: blender/source/blender/python/BPY_interface.c
===================================================================
443,445c443
< 
<     BPY_Err_Handle(GetName(st->text));
< ReleaseGlobalDictionary(py_dict);
---
> BPY_Err_Handle(GetName(t));

I ran a negative test (e.g., a Python script with a syntax error), and got a 
crash.  I found that ReleaseGlobalDictionary does this:

  PyDict_Clear (dict);
  Py_DECREF (dict);   /* Release dictionary. */

However, free_libblock eventually calls BPY_clear_script, which does the same 
thing.  So I presumed there was some kind of double-free happening.  While 
re-reading this code, I noticed that the same thing happens in BPY_interface.c, 
a few lines later (in the "else" clause):

  script->flags &=~SCRIPT_RUNNING;
  if (!script->flags) {
   ReleaseGlobalDictionary(py_dict);
   script->py_globaldict = NULL;
   free_libblock(&G.main->script, script);
  }

I don't know why this isn't causing the same crash (unless the script flags 
are never empty, so this code isn't executed).  Someone with more experience in 
the Blender code should probably take a look at it.

Hope this helps to explain things.

best regards,
Chris Keith (chrisNO_SPAMkeith at aol.com)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20040216/15589026/attachment.html>


More information about the Bf-python mailing list