Blender crash on GPUFrameBuffer creation #88345

Closed
opened 2021-05-17 11:45:51 +02:00 by Alexander Samsonov · 13 comments

System Information
Operating system: Ubuntu 20.04, MacOS 11 Big Sur
Graphics card: Nvidia RTX 2060 (Radeon HD 5770, Intel i5 Iris Plus)

Blender Version
Broken: 2.93.0 Beta

Short description of error
Binding color slots to GPUFrameBuffer crashes blender

Exact steps for others to reproduce the error
Just try to run the following code from text editor:

import gpu
buffer = gpu.types.Buffer('FLOAT',(16, 16, 4))
color = [gpu.types.GPUTexture((16, 16), format='RGBA32F', data=buffer)]
FBO = gpu.types.GPUFrameBuffer(color_slots = color)

The last line crashes blender. Although binding only the depth buffer works:

import gpu
buffer = gpu.types.Buffer('FLOAT',(16, 16, 1))
depth = gpu.types.GPUTexture((16, 16), format='DEPTH_COMPONENT16', data=buffer)
FBO = gpu.types.GPUFrameBuffer(depth_slot = depth)

The crash report doesn't look informative

# backtrace
blender-2.93/blender(BLI_system_backtrace+0x20) [0xa5981a0]
blender-2.93/blender() [0xf625aa]
/lib/x86_64-linux-gnu/libc.so.6(+0x46210) [0x7fa01a2ba210]
blender-2.93/blender() [0x25f3924]
blender-2.93/blender() [0x8770706]
blender-2.93/blender(_PyObject_MakeTpCall+0x90) [0x8719320]
blender-2.93/blender(_PyEval_EvalFrameDefault+0x625c) [0xf5be3c]
blender-2.93/blender() [0x87c6ac4]
blender-2.93/blender(_PyEval_EvalCodeWithName+0x4e) [0x87c6e0e]
blender-2.93/blender(PyEval_EvalCodeEx+0x3e) [0x87c6e5e]
blender-2.93/blender(PyEval_EvalCode+0x1b) [0x87c6e8b]
blender-2.93/blender() [0x1870a61]
blender-2.93/blender() [0x1d296ce]
blender-2.93/blender() [0x1310fe8]
blender-2.93/blender() [0x131153b]
blender-2.93/blender(WM_operator_name_call_ptr+0x1a) [0x1311a6a]
blender-2.93/blender() [0x1c05038]
blender-2.93/blender() [0x1c15d65]
blender-2.93/blender() [0x131512e]
blender-2.93/blender() [0x13157dc]
blender-2.93/blender(wm_event_do_handlers+0x426) [0x1315f26]
blender-2.93/blender(WM_main+0x20) [0x130c740]
blender-2.93/blender(main+0x31e) [0xe89f2e]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7fa01a29b0b3]
blender-2.93/blender() [0xf5ef2c]

# Python backtrace
  File "/Text", line 5 in <module>

Maybe I'm doing something terribly wrong but it seems that such code should not crash blender anyway

**System Information** Operating system: Ubuntu 20.04, MacOS 11 Big Sur Graphics card: Nvidia RTX 2060 (Radeon HD 5770, Intel i5 Iris Plus) **Blender Version** Broken: 2.93.0 Beta **Short description of error** Binding color slots to GPUFrameBuffer crashes blender **Exact steps for others to reproduce the error** Just try to run the following code from text editor: ``` import gpu buffer = gpu.types.Buffer('FLOAT',(16, 16, 4)) color = [gpu.types.GPUTexture((16, 16), format='RGBA32F', data=buffer)] FBO = gpu.types.GPUFrameBuffer(color_slots = color) ``` The last line crashes blender. Although binding only the depth buffer works: ``` import gpu buffer = gpu.types.Buffer('FLOAT',(16, 16, 1)) depth = gpu.types.GPUTexture((16, 16), format='DEPTH_COMPONENT16', data=buffer) FBO = gpu.types.GPUFrameBuffer(depth_slot = depth) ``` The crash report doesn't look informative ``` # backtrace blender-2.93/blender(BLI_system_backtrace+0x20) [0xa5981a0] blender-2.93/blender() [0xf625aa] /lib/x86_64-linux-gnu/libc.so.6(+0x46210) [0x7fa01a2ba210] blender-2.93/blender() [0x25f3924] blender-2.93/blender() [0x8770706] blender-2.93/blender(_PyObject_MakeTpCall+0x90) [0x8719320] blender-2.93/blender(_PyEval_EvalFrameDefault+0x625c) [0xf5be3c] blender-2.93/blender() [0x87c6ac4] blender-2.93/blender(_PyEval_EvalCodeWithName+0x4e) [0x87c6e0e] blender-2.93/blender(PyEval_EvalCodeEx+0x3e) [0x87c6e5e] blender-2.93/blender(PyEval_EvalCode+0x1b) [0x87c6e8b] blender-2.93/blender() [0x1870a61] blender-2.93/blender() [0x1d296ce] blender-2.93/blender() [0x1310fe8] blender-2.93/blender() [0x131153b] blender-2.93/blender(WM_operator_name_call_ptr+0x1a) [0x1311a6a] blender-2.93/blender() [0x1c05038] blender-2.93/blender() [0x1c15d65] blender-2.93/blender() [0x131512e] blender-2.93/blender() [0x13157dc] blender-2.93/blender(wm_event_do_handlers+0x426) [0x1315f26] blender-2.93/blender(WM_main+0x20) [0x130c740] blender-2.93/blender(main+0x31e) [0xe89f2e] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7fa01a29b0b3] blender-2.93/blender() [0xf5ef2c] # Python backtrace File "/Text", line 5 in <module> ``` Maybe I'm doing something terribly wrong but it seems that such code should not crash blender anyway

Added subscriber: @blendersamsonov

Added subscriber: @blendersamsonov
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

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

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

Passing a tuple (instead of a list) works on my end:

import gpu
buffer = gpu.types.Buffer('FLOAT',(16, 16, 4))
color = (gpu.types.GPUTexture((16, 16), format='RGBA32F', data=buffer))
FBO = gpu.types.GPUFrameBuffer(color_slots = color)

Can confirm the crash though, should not happen.

Passing a tuple (instead of a list) works on my end: ``` import gpu buffer = gpu.types.Buffer('FLOAT',(16, 16, 4)) color = (gpu.types.GPUTexture((16, 16), format='RGBA32F', data=buffer)) FBO = gpu.types.GPUFrameBuffer(color_slots = color) ``` Can confirm the crash though, should not happen.

In your case color variable actually has a GPUTexture type. Passing real tuple like that also crashes blender:

import gpu
buffer = gpu.types.Buffer('FLOAT',(16, 16, 4))
color = (gpu.types.GPUTexture((16, 16), format='RGBA32F', data=buffer),)
FBO = gpu.types.GPUFrameBuffer(color_slots = color)

Although passing a tuple generator actually works as expected

import gpu
buffers = [gpu.types.Buffer('FLOAT',(16, 16, 4)) for i in range(3)]
color = (gpu.types.GPUTexture((16, 16), format='RGBA32F', data=buffers[i]) for i in range(3))
FBO = gpu.types.GPUFrameBuffer(color_slots = color)

Implicit casting should be implemented though

@lichtwerk thanks for directing to the workaround anyway!

In your case `color` variable actually has a `GPUTexture` type. Passing real tuple like that also crashes blender: ``` import gpu buffer = gpu.types.Buffer('FLOAT',(16, 16, 4)) color = (gpu.types.GPUTexture((16, 16), format='RGBA32F', data=buffer),) FBO = gpu.types.GPUFrameBuffer(color_slots = color) ``` Although passing a tuple generator actually works as expected ``` import gpu buffers = [gpu.types.Buffer('FLOAT',(16, 16, 4)) for i in range(3)] color = (gpu.types.GPUTexture((16, 16), format='RGBA32F', data=buffers[i]) for i in range(3)) FBO = gpu.types.GPUFrameBuffer(color_slots = color) ``` Implicit casting should be implemented though @lichtwerk thanks for directing to the workaround anyway!
Member

Added subscriber: @mano-wii

Added subscriber: @mano-wii
Member

First I was confused about starting with index 1 here https://developer.blender.org/diffusion/B/browse/master/source/blender/python/gpu/gpu_py_framebuffer.c$326.
But that does not seem to be the real underlying issue

@mano-wii: even if this is "wrong" usage, can we prevent the crash?

First I was confused about starting with index 1 here https://developer.blender.org/diffusion/B/browse/master/source/blender/python/gpu/gpu_py_framebuffer.c$326. But that does not seem to be the real underlying issue @mano-wii: even if this is "wrong" usage, can we prevent the crash?
Member

In #88345#1162123, @blendersamsonov wrote:
In your case color variable actually has a GPUTexture type. Passing real tuple like that also crashes blender:

doh

Implicit casting should be implemented though

thx digging @blendersamsonov

> In #88345#1162123, @blendersamsonov wrote: > In your case `color` variable actually has a `GPUTexture` type. Passing real tuple like that also crashes blender: > doh > Implicit casting should be implemented though thx digging @blendersamsonov

btw, seems like I found another bug in the current gpu implementation: https://developer.blender.org/T88365. It might be not directly related but still

btw, seems like I found another bug in the current `gpu` implementation: https://developer.blender.org/T88365. It might be not directly related but still

In #88345#1162143, @lichtwerk wrote:
First I was confused about starting with index 1 here https://developer.blender.org/diffusion/B/browse/master/source/blender/python/gpu/gpu_py_framebuffer.c$326.

Nice catch, in fact it was a confusion between the index of color_attachements and config during the implementation.
It seems like a simple fix.

> In #88345#1162143, @lichtwerk wrote: > First I was confused about starting with index 1 here https://developer.blender.org/diffusion/B/browse/master/source/blender/python/gpu/gpu_py_framebuffer.c$326. Nice catch, in fact it was a confusion between the index of `color_attachements` and `config` during the implementation. It seems like a simple fix.

This issue was referenced by 4bb2a5b5cb

This issue was referenced by 4bb2a5b5cb700d4564603f882c750eca5544bde6

This issue was referenced by ea7b00c64f

This issue was referenced by ea7b00c64fcd3bcff4a4d1455e0ef334bdd6a6ec

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Germano Cavalcante self-assigned this 2021-05-18 14:40:13 +02: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
4 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#88345
No description provided.