Crash with new Datablock ID Properties #51198

Closed
opened 2017-04-13 15:17:54 +02:00 by Simon Wendsche · 16 comments

Short description of error
Blender crashes when an object with the new Datablock ID Properties a7b3047cef references itself or when two objects reference each other.

Exact steps for others to reproduce the error

  • Open default scene (Camera, Cube, Lamp) or use the attached .blend
  • Run this script:
import bpy

bpy.types.Object.prop = bpy.props.PointerProperty(type=bpy.types.Object)

cube = bpy.data.objects['Cube']
lamp = bpy.data.objects['Lamp']
camera = bpy.data.objects['Camera']

# init the props so we can edit them in the Custom Properties panel
cube.prop = camera
lamp.prop = camera
  • Now this scene can lead to two crashes I discovered so far:

  • Crash 1:

  • select cube, choose Lamp from prop dropdown in Custom Properties

  • select lamp, choose Cube from prop dropdown in Custom Properties

  • crash

  • Crash 2:

  • select cube, choose Cube from prop dropdown in Custom Properties

  • crash

Edit: Important detail I forgot:
It only happens when setting the prop value by hand, not when it is done in Python.
The Python script can't trigger the crash, for example this line works (while it crashes when done by hand):

cube.prop = cube

System Information
Linux 64 bit (Ubuntu 14.04)

Blender Version
Broken: 2.78 575d641 (says the splashscreen, I built from Blender master, so it's 2.79dev)scrn_13-04-2017_15-16-32.png

datablock_crash.blend

**Short description of error** Blender crashes when an object with the new [Datablock ID Properties ](https://developer.blender.org/D113) a7b3047cefcb references itself or when two objects reference each other. **Exact steps for others to reproduce the error** * Open default scene (Camera, Cube, Lamp) or use the attached .blend * Run this script: ``` import bpy bpy.types.Object.prop = bpy.props.PointerProperty(type=bpy.types.Object) cube = bpy.data.objects['Cube'] lamp = bpy.data.objects['Lamp'] camera = bpy.data.objects['Camera'] # init the props so we can edit them in the Custom Properties panel cube.prop = camera lamp.prop = camera ``` * Now this scene can lead to two crashes I discovered so far: * Crash 1: * select cube, choose Lamp from prop dropdown in Custom Properties * select lamp, choose Cube from prop dropdown in Custom Properties * crash * Crash 2: * select cube, choose Cube from prop dropdown in Custom Properties * crash **Edit: Important detail I forgot:** It only happens when setting the prop value by hand, not when it is done in Python. The Python script can't trigger the crash, for example this line works (while it crashes when done by hand): ``` cube.prop = cube ``` **System Information** Linux 64 bit (Ubuntu 14.04) **Blender Version** Broken: 2.78 575d641 (says the splashscreen, I built from Blender master, so it's 2.79dev)![scrn_13-04-2017_15-16-32.png](https://archive.blender.org/developer/F544485/scrn_13-04-2017_15-16-32.png) [datablock_crash.blend](https://archive.blender.org/developer/F544487/datablock_crash.blend)
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @BYOB

Added subscriber: @BYOB

Added subscriber: @SteffenD

Added subscriber: @SteffenD

Added subscriber: @bliblubli

Added subscriber: @bliblubli
Alexander Romanov was assigned by mathieu menuet 2017-04-13 19:11:36 +02:00
Member

Added subscriber: @mont29

Added subscriber: @mont29

I've found the reason for this crash, and also found forward compatibility issue. I'm working on it.

I've found the reason for this crash, and also found forward compatibility issue. I'm working on it.

The reason of crash is infinite recursion, which happens in RNA_pointer_as_string.
I've also found python crash if you will try to remove the custom property pressing "-" button.
This is my solution for these two issues: P464

And one issue with forward compatibility, which I couldn't solve yet:
crash inside

PropertyType RNA_property_type(PropertyRNA *prop)
{
	return rna_ensure_property(prop)->type;
}

rna_ensure_property always returns NULL for IDP_ID for Blender builds before D113. This crash happens for me only when I'm opening "Custom Properties" panel.
@mont29, could you help please?

The reason of crash is infinite recursion, which happens in RNA_pointer_as_string. I've also found python crash if you will try to remove the custom property pressing "-" button. This is my solution for these two issues: [P464](https://archive.blender.org/developer/P464.txt) And one issue with forward compatibility, which I couldn't solve yet: crash inside ``` PropertyType RNA_property_type(PropertyRNA *prop) { return rna_ensure_property(prop)->type; } ``` rna_ensure_property always returns NULL for IDP_ID for Blender builds before [D113](https://archive.blender.org/developer/D113). This crash happens for me only when I'm opening "Custom Properties" panel. @mont29, could you help please?

Possible solution for forward compatibility issue: P465

Possible solution for forward compatibility issue: [P465](https://archive.blender.org/developer/P465.txt)

Added subscribers: @Sergey, @ideasman42

Added subscribers: @Sergey, @ideasman42

@AlexanderRomanov mostly fine with P464 (rna part of it at least, not convinced by python changes there).

But P465 is a no-go for me, imho it is totally unacceptable to twist that way our .blend file just to ensure forward compat (not to mention how evil it is to change actual data, even if only for a few micro seconds, in writefile!). I’m tempted to consider this a bug in previous blender (if a function can return NULL and is not checked, then bug is in code using it). Can only think about protecting against this for future (e.g. by nuking IDProps of unknown type at read time, keeping them around is call for issues anyway at some point)… Would not mind @Sergey or @ideasman42 input here though.

@AlexanderRomanov mostly fine with [P464](https://archive.blender.org/developer/P464.txt) (rna part of it at least, not convinced by python changes there). But [P465](https://archive.blender.org/developer/P465.txt) is a no-go for me, imho it is totally unacceptable to twist that way our .blend file just to ensure forward compat (not to mention how evil it is to change actual data, even if only for a few micro seconds, in writefile!). I’m tempted to consider this a bug in previous blender (if a function can return NULL and is not checked, then bug is in code using it). Can only think about protecting against this for future (e.g. by nuking IDProps of unknown type at read time, keeping them around is call for issues anyway at some point)… Would not mind @Sergey or @ideasman42 input here though.

@mont29 for first part of P464 I've recorded the video: https://youtu.be/jF0CtWQPsC4

@mont29 for first part of [P464](https://archive.blender.org/developer/P464.txt) I've recorded the video: https://youtu.be/jF0CtWQPsC4

@AlexanderRomanov aaaah oki, see the issue now. But this -remove property' button makes absolutely no sense for API-defined IDProps! Nuked it in 42c8d93c5f. ;)

So you can commit the RNA part of P464.

For the forward compat issue, we need advice from other devs. ;)

@AlexanderRomanov aaaah oki, see the issue now. But this -remove property' button makes absolutely no sense for API-defined IDProps! Nuked it in 42c8d93c5f. ;) So you can commit the RNA part of [P464](https://archive.blender.org/developer/P464.txt). For the forward compat issue, we need advice from other devs. ;)

@mont29, we indeed should not modify anything from the main database during file save. This was known for giving issues in the past. What i remember happening at some point is that we were constructing temp copy of the objects and made modifications on those. Need to be careful tho, because that will modify pointers of the struct itself.

@mont29, we indeed should not modify anything from the main database during file save. This was known for giving issues in the past. What i remember happening at some point is that we were constructing temp copy of the objects and made modifications on those. Need to be careful tho, because that will modify pointers of the struct itself.

@Sergey yes, temp structs is the way to go here - while keeping orig pointer one as 'uuid' (pointer value in file), to ensure re-allocating temp memory later in write process does not re-use same mem pointer…

But that’s not the main issue here, main issue is that P465 horribly tweaks IDProps to save them in a way that new pointer IDProps do not make older blender crash when loading a file saved with those new properties. Imho this is not really acceptable, especially since the root of the issue remains - should we introduce a new IDProp type in the future, it will again make older Blender crash. So to me this is a bug in current code, that is trivial to fix (e.g. by removing any unknown IDProp type at read time), but we should not try to fix this for previous versions… As ugly as it is :(

@Sergey yes, temp structs is the way to go here - while keeping orig pointer one as 'uuid' (pointer value in file), to ensure re-allocating temp memory later in write process does not re-use same mem pointer… But that’s not the main issue here, main issue is that [P465](https://archive.blender.org/developer/P465.txt) horribly tweaks IDProps to save them in a way that new pointer IDProps do not make older blender crash when loading a file saved with those new properties. Imho this is not really acceptable, especially since the root of the issue remains - should we introduce a new IDProp type in the future, it will again make older Blender crash. So to me this is a bug in current code, that is trivial to fix (e.g. by removing any unknown IDProp type at read time), but we should not try to fix this for previous versions… As ugly as it is :(

This issue was referenced by 31c644b657

This issue was referenced by 31c644b657d3dbfaa170e5893fcd69ea5b87d670

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
8 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#51198
No description provided.