[Bf-blender-cvs] [9ca80d75647] temp-asset-representation: Workaround crash generating Python API documentation
Campbell Barton
noreply at git.blender.org
Tue Nov 8 12:42:27 CET 2022
Commit: 9ca80d75647d7d54fea676ced94d753e9a1d633b
Author: Campbell Barton
Date: Tue Nov 8 16:43:16 2022 +1100
Branches: temp-asset-representation
https://developer.blender.org/rB9ca80d75647d7d54fea676ced94d753e9a1d633b
Workaround crash generating Python API documentation
Avoid accessing freed memory from dynamically allocated EnumPropertyItem
arrays. Rely on the memory being held by the iterator which isn't the
case when it was converted to a tuple.
===================================================================
M release/scripts/modules/rna_info.py
===================================================================
diff --git a/release/scripts/modules/rna_info.py b/release/scripts/modules/rna_info.py
index e2bbc4077a1..07daf7c55eb 100644
--- a/release/scripts/modules/rna_info.py
+++ b/release/scripts/modules/rna_info.py
@@ -286,7 +286,10 @@ class InfoPropertyRNA:
self.enum_pointer = 0
if self.type == "enum":
- items = tuple(rna_prop.enum_items)
+ # WARNING: don't convert to a tuple as this causes dynamically allocated enums to access freed memory
+ # since freeing the iterator may free the memory used to store the internal `EnumPropertyItem` array.
+ # To support this properly RNA would have to support owning the dynamically allocated memory.
+ items = rna_prop.enum_items
items_static = tuple(rna_prop.enum_items_static)
self.enum_items[:] = [(item.identifier, item.name, item.description) for item in items]
self.is_enum_flag = rna_prop.is_enum_flag
@@ -295,6 +298,7 @@ class InfoPropertyRNA:
item = (items_static or items)
if item:
self.enum_pointer = item[0].as_pointer()
+ del items, items_static, item
else:
self.is_enum_flag = False
More information about the Bf-blender-cvs
mailing list