Undefined behavior happen by copying objects with Ctrl+C with custom material nodes #54019

Closed
opened 2018-02-07 16:17:29 +01:00 by Bogdan Nagirniak · 11 comments

System Information
Windows 10

Blender Version
Broken: 2.79 5bd8ac9

Short description of error
Copying objects by Ctrl+C with custom material nodes (created in python by class MyCustomSocket(bpy.types.NodeSocket) .... ) produced undefined behavior in Blender, after which Blender crashes.

Raw diff how to fix this bug
Did more deep investigation of this bug inside Blender's source code and found how this could be fixed. Here it is raw diff: https://pastebin.com/SzwwpCnn

**System Information** Windows 10 **Blender Version** Broken: 2.79 5bd8ac9 **Short description of error** Copying objects by Ctrl+C with custom material nodes (created in python by class MyCustomSocket(bpy.types.NodeSocket) .... ) produced undefined behavior in Blender, after which Blender crashes. **Raw diff how to fix this bug** Did more deep investigation of this bug inside Blender's source code and found how this could be fixed. Here it is raw diff: https://pastebin.com/SzwwpCnn
Author
Member

Added subscriber: @bnagirniak

Added subscriber: @bnagirniak

Added subscriber: @bliblubli

Added subscriber: @bliblubli

thanks for investigating. Can you please attach a file and the according steps to reproduce the crash?

thanks for investigating. Can you please attach a file and the according steps to reproduce the crash?
Author
Member

Well, I'm one of the developers of Radeon ProRender plugin for Blender https://pro.radeon.com/en/software/prorender/blender/ and there (inside plugin) we use our custom materials.

Here are the steps to reproduce bug:

  1. Install RadeonRpoRender plugin https://www2.ati.com/other/radeonprorenderforblender.1.5.0.msi
  2. Create new scene and select Radeon ProRender engine
  3. Select any object (box by default).
  4. Assign RPR Diffuse material to this object.
  5. Press Ctrl+C to copy object to buffer -> Blender crashes because of undefined behavior.

Anyway, currently in Blender when we press Ctrl+C in source code we have following:

  • readfile.c: line 9177: expand_doit(fd, mainvar, sock->prop); //where expand_doit is a pointer to function blendfile_write_partial_cb() and sock->prop has type IDProperty*
  • inside blendfile_write_partial_cb(): sock->prop is trying to be cast into ID* and be used as ID*. But IDProperty cannot be cast to ID and this produces undefined behavior.

I'm proposing to fix this bug by changing lines expand_doit(fd, mainvar, sock->prop); into expand_idprops(fd, mainvar, sock->prop); in the expand_nodetree() function where it has to be required in a raw diff link.

Thank you!

Well, I'm one of the developers of Radeon ProRender plugin for Blender https://pro.radeon.com/en/software/prorender/blender/ and there (inside plugin) we use our custom materials. Here are the steps to reproduce bug: 1. Install RadeonRpoRender plugin https://www2.ati.com/other/radeonprorenderforblender.1.5.0.msi 2. Create new scene and select Radeon ProRender engine 3. Select any object (box by default). 4. Assign RPR Diffuse material to this object. 5. Press Ctrl+C to copy object to buffer -> Blender crashes because of undefined behavior. Anyway, currently in Blender when we press Ctrl+C in source code we have following: - readfile.c: line 9177: expand_doit(fd, mainvar, sock->prop); //where expand_doit is a pointer to function blendfile_write_partial_cb() and sock->prop has type IDProperty* - inside blendfile_write_partial_cb(): sock->prop is trying to be cast into ID* and be used as ID*. But IDProperty cannot be cast to ID and this produces undefined behavior. I'm proposing to fix this bug by changing lines expand_doit(fd, mainvar, sock->prop); into expand_idprops(fd, mainvar, sock->prop); in the expand_nodetree() function where it has to be required in a raw diff link. Thank you!
Member

Added subscriber: @LazyDodo

Added subscriber: @LazyDodo
Member

i can't seem to reproduce this with the custom nodes template, there has to be an easier way to reproduce this beyond installing a 500mb+ addon.

i can't seem to reproduce this with the custom nodes template, there has to be an easier way to reproduce this beyond installing a 500mb+ addon.

This issue was referenced by b65933e7b3

This issue was referenced by b65933e7b313c5dd857280dd5cc4fb9c44e0e83d

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Added subscriber: @brecht

Added subscriber: @brecht

The code here is clearly wrong, we should not be passing an ID property to a function that expects and ID. So I committed the patch.

The code here is clearly wrong, we should not be passing an ID property to a function that expects and ID. So I committed the patch.
Author
Member

Thank you!

Thank you!
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
5 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#54019
No description provided.