Crash when modifying strength of world environment texture #94736

Closed
opened 2022-01-08 10:59:23 +01:00 by Leonard Göttert · 15 comments

System Information
Operating system: macOS-12.1-arm64-arm-64bit 64 Bits
Graphics card: Apple M1 Pro Apple 4.1 Metal - 76.3

Blender Version
Broken: version: 3.1.0 Alpha, branch: master, commit date: 2022-01-07 23:28, hash: 741ed5fcd2

Short description of error
When viewing a scene using Viewport Shading with Cycles on Metal, Blender crashes when playing with the Strength value of the World Background Surface.
Bildschirmfoto 2022-01-08 um 10.48.28.png

Exact steps for others to reproduce the error

  • Open attached .blend file. It just contains a cube and an environment texture on the world background surface.
    blender crash.blend
  • Go into viewport shading mode.
  • Modify the strength value. The crash happens both using click-dragging as well as repeatedly entering values numerically. It does not always crash immediately, but for me it always crashes within a couple of seconds.
**System Information** Operating system: macOS-12.1-arm64-arm-64bit 64 Bits Graphics card: Apple M1 Pro Apple 4.1 Metal - 76.3 **Blender Version** Broken: version: 3.1.0 Alpha, branch: master, commit date: 2022-01-07 23:28, hash: `741ed5fcd2` **Short description of error** When viewing a scene using Viewport Shading with Cycles on Metal, Blender crashes when playing with the Strength value of the World Background Surface. ![Bildschirmfoto 2022-01-08 um 10.48.28.png](https://archive.blender.org/developer/F12795414/Bildschirmfoto_2022-01-08_um_10.48.28.png) **Exact steps for others to reproduce the error** * Open attached .blend file. It just contains a cube and an environment texture on the world background surface. [blender crash.blend](https://archive.blender.org/developer/F12795845/blender_crash.blend) * Go into viewport shading mode. * Modify the strength value. The crash happens both using click-dragging as well as repeatedly entering values numerically. It does not always crash immediately, but for me it always crashes within a couple of seconds.

Added subscriber: @Leonard-Gottert

Added subscriber: @Leonard-Gottert

#94912 was marked as duplicate of this issue

#94912 was marked as duplicate of this issue

Added subscriber: @blenderrocket

Added subscriber: @blenderrocket

For others to replicate this, you should probably add the exr or pack it in the blend file.

For others to replicate this, you should probably add the exr or pack it in the blend file.

I get the same result as you in rendered view.

System Information
Operating system: macOS-12.1-arm64-arm-64bit 64 Bits
Graphics card: Apple M1 Max Apple 4.1 Metal - 76.3

Blender Version
Broken: version: 3.1.0 Alpha, branch: master, commit date: 2022-01-07 23:28, hash: 741ed5fcd2

Crash report:
Crash blender.txt

I get the same result as you in rendered view. **System Information** Operating system: macOS-12.1-arm64-arm-64bit 64 Bits Graphics card: Apple M1 Max Apple 4.1 Metal - 76.3 **Blender Version** Broken: version: 3.1.0 Alpha, branch: master, commit date: 2022-01-07 23:28, hash: `741ed5fcd2` Crash report: [Crash blender.txt](https://archive.blender.org/developer/F12795851/Crash_blender.txt)

I packed the exr file into the .blend file and edited the original post.

I packed the exr file into the .blend file and edited the original post.

Added subscribers: @Michael-Jones, @michael64

Added subscribers: @Michael-Jones, @michael64

This is a case of use-after-free error.
One could apply P2707, then build and run Blender with this scene as described
and see the following log messages when reducing the surface strength from 1.000 to 0.900:

reached useful breakpoint site at intern/cycles/device/metal/device_impl.mm:535
generic_free at intern/cycles/device/metal/device_impl.mm:558 generic_free mmem: 0x2c04fe780  mmem.mtlBuffer: 0x17f153cc0  size: 67125248
enqueue in intern/cycles/device/metal/queue.mm:217 accessing mmem: 0x2c04fe780  mmem->mtlBuffer: 0x2  mmem->size: 0  pointer_index: 36
The mmem->mtlBuffer was deleted in another MetalDevice::MetalMem struct and -[MTLArgumentEncoder setBuffer:offset:atIndex:] would have crashed here

So first a MetalDevice::MetalMem struct is freed by way of LightManager::device_free which seems correct.
The memory of this struct is now free and undefined and will be reused immediately that is why we get a mmem->mtlBuffer of 0x2 and a mmem->size of 0 later.
In MetalDeviceQueue::enqueue the memory address of this freed region is pulled in via &metal_device->launch_params + offset
and -[MTLArgumentEncoder setBuffer:offset:atIndex:] is called with invalid parameter values.
Because accidentally mmem->size is 0 at this point this can be used to set a nice breakpoint for debugging but we should not even have this memory reference any more.
Maybe @Michael-Jones can have a look at this?

This is a case of use-after-free error. One could apply [P2707](https://archive.blender.org/developer/P2707.txt), then build and run Blender with this scene as described and see the following log messages when reducing the surface strength from 1.000 to 0.900: ``` reached useful breakpoint site at intern/cycles/device/metal/device_impl.mm:535 generic_free at intern/cycles/device/metal/device_impl.mm:558 generic_free mmem: 0x2c04fe780 mmem.mtlBuffer: 0x17f153cc0 size: 67125248 enqueue in intern/cycles/device/metal/queue.mm:217 accessing mmem: 0x2c04fe780 mmem->mtlBuffer: 0x2 mmem->size: 0 pointer_index: 36 The mmem->mtlBuffer was deleted in another MetalDevice::MetalMem struct and -[MTLArgumentEncoder setBuffer:offset:atIndex:] would have crashed here ``` So first a MetalDevice::MetalMem struct is freed by way of LightManager::device_free which seems correct. The memory of this struct is now free and undefined and will be reused immediately that is why we get a mmem->mtlBuffer of 0x2 and a mmem->size of 0 later. In MetalDeviceQueue::enqueue the memory address of this freed region is pulled in via `&metal_device->launch_params + offset` and -[MTLArgumentEncoder setBuffer:offset:atIndex:] is called with invalid parameter values. Because accidentally `mmem->size` is 0 at this point this can be used to set a nice breakpoint for debugging but we should not even have this memory reference any more. Maybe @Michael-Jones can have a look at this?

Added subscriber: @AledBrown

Added subscriber: @AledBrown

Added subscriber: @deadpin

Added subscriber: @deadpin

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'

Will confirm since it seems legit and many folks are running into this.

Will confirm since it seems legit and many folks are running into this.

This issue was referenced by blender/cycles@20cc512a78

This issue was referenced by blender/cycles@20cc512a7852cf6b768b5e36b89ec764a2daa886

This issue was referenced by 17cab47ed1

This issue was referenced by 17cab47ed10a99818f9cdd15657c1231e312da25

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Michael Jones (Apple) self-assigned this 2022-01-19 19:17:53 +01:00
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
6 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#94736
No description provided.