Segfault populating popup menu with specific structure, scale_x, and element count. (GPUOffScreen buffer too large?) #89782

Closed
opened 2021-07-11 06:29:58 +02:00 by Will · 12 comments

System Information
Operating system: Linux
Graphics card: Intel

Blender Version
Broken: 2.93.0

Short description of error

I have a very specific UI hierarchy and settings that are consistently causing segfaults for me.

I think the short draw code is the best way to explain it:

def draw(self, context):
		layout = self.layout
		row = layout.row(align=True)
		row.scale_x = 2 # Needed for crash.
		col1 = row.column(align=True)
		col2 = row.column(align=True)
		for i in range(40): # Crashes with 40 and 39, but not with 20, 50, or 100.
			col1.label(text=str("a"*20)) #Doesn't matter, I think.
			col2.label(text=str("b"*20))

bpy.context.window_manager.popup_menu(draw, title="")

.scale_x = 2 is needed for the crash. The number of items from the range() also matters, and won't crash with too few or too many. I don't think the lengths of the labels matter.

  • Also happens with column/row layout convoluted/zipped.

  • Also happens with .ui_units_x = 40 replacing .scale_x = 2 (but not with all other values of .ui_units_x).

  • Actually seems to happen with some number (but not all numbers) of elements for any combination of UI dimensions in .popup_menu.

  • Note: Even when it doesn't segfault, the popup menu will often be an obvious rendering error with lots of tearing and such.

Exact steps for others to reproduce the error

Run the script:

ScaleXCrash.blend

**System Information** Operating system: Linux Graphics card: Intel **Blender Version** Broken: 2.93.0 **Short description of error** I have a very specific UI hierarchy and settings that are consistently causing segfaults for me. I think the short draw code is the best way to explain it: ``` def draw(self, context): layout = self.layout row = layout.row(align=True) row.scale_x = 2 # Needed for crash. col1 = row.column(align=True) col2 = row.column(align=True) for i in range(40): # Crashes with 40 and 39, but not with 20, 50, or 100. col1.label(text=str("a"*20)) #Doesn't matter, I think. col2.label(text=str("b"*20)) bpy.context.window_manager.popup_menu(draw, title="") ``` `.scale_x = 2` is needed for the crash. The number of items from the `range()` also matters, and won't crash with too few or too many. I don't think the lengths of the labels matter. * Also happens with column/row layout convoluted/zipped. * Also happens with `.ui_units_x = 40` replacing `.scale_x = 2` (but not with all other values of `.ui_units_x`). * Actually seems to happen with some number (but not all numbers) of elements for any combination of UI dimensions in `.popup_menu`. * Note: Even when it doesn't segfault, the popup menu will often be an obvious rendering error with lots of tearing and such. **Exact steps for others to reproduce the error** Run the script: [ScaleXCrash.blend](https://archive.blender.org/developer/F10220173/ScaleXCrash.blend)
Author

Added subscriber: @WCN

Added subscriber: @WCN
Member

Added subscriber: @PratikPB2123

Added subscriber: @PratikPB2123
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

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

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

Can confirm.

note: does not happen if scale_x stays below 1 (at least here on my end)

Read blend: /ScaleXCrash.blend
./bin/blender(BLI_system_backtrace+0x26) [0x1030274e]
./bin/blender(_BLI_assert_print_backtrace+0x16) [0x101d669e]
./bin/blender(BLI_vsnprintf+0x24) [0x102f65da]
./bin/blender(BLI_snprintf+0xaa) [0x102f688c]
./bin/blender(GPU_offscreen_create+0x10f) [0xe1e34c1]
./bin/blender() [0x3d1ec83]
./bin/blender() [0x3d1f97b]
./bin/blender() [0x3d1fe02]
./bin/blender(wm_draw_update+0xc5) [0x3d2043a]
./bin/blender(WM_main+0x48) [0x3d1ca65]
./bin/blender() [0x36c665a]
/lib64/libc.so.6(+0x2b7e0) [0x7fc3290897e0]
/lib64/libc.so.6(__libc_start_main+0x7c) [0x7fc32908988c]
./bin/blender(_start+0x25) [0x36c6035]
BLI_assert failed: source/blender/blenlib/intern/string.c:218, BLI_vsnprintf(), at 'buffer != ((void *)0)'
Can confirm. note: does not happen if `scale_x` stays below 1 (at least here on my end) ``` Read blend: /ScaleXCrash.blend ./bin/blender(BLI_system_backtrace+0x26) [0x1030274e] ./bin/blender(_BLI_assert_print_backtrace+0x16) [0x101d669e] ./bin/blender(BLI_vsnprintf+0x24) [0x102f65da] ./bin/blender(BLI_snprintf+0xaa) [0x102f688c] ./bin/blender(GPU_offscreen_create+0x10f) [0xe1e34c1] ./bin/blender() [0x3d1ec83] ./bin/blender() [0x3d1f97b] ./bin/blender() [0x3d1fe02] ./bin/blender(wm_draw_update+0xc5) [0x3d2043a] ./bin/blender(WM_main+0x48) [0x3d1ca65] ./bin/blender() [0x36c665a] /lib64/libc.so.6(+0x2b7e0) [0x7fc3290897e0] /lib64/libc.so.6(__libc_start_main+0x7c) [0x7fc32908988c] ./bin/blender(_start+0x25) [0x36c6035] BLI_assert failed: source/blender/blenlib/intern/string.c:218, BLI_vsnprintf(), at 'buffer != ((void *)0)' ```
Member

Added subscriber: @mano-wii

Added subscriber: @mano-wii
Member

It is just that the GPUOffScreen buffer would be too large it seems and cannot be created.

The assert can be avoided by the following (but still -- this should be safeguarded against more thoroughly since this gets blender into total unstable land):
{P2246}

@mano-wii: is this something you can look into?

It is just that the `GPUOffScreen` buffer would be too large it seems and cannot be created. The assert can be avoided by the following (but still -- this should be safeguarded against more thoroughly since this gets blender into total unstable land): {P2246} @mano-wii: is this something you can look into?
Philipp Oeser changed title from Segfault populating popup menu with specific structure, `scale_x`, and element count. to Segfault populating popup menu with specific structure, `scale_x`, and element count. (GPUOffScreen buffer too large?) 2021-07-12 15:52:13 +02:00

The error is in the internals of the GPU module. Not much related to the python API
The crash happens because the offscreen texture has dimensions above the OpenGL limit, and GPU_offscreen_create requires a non-NULL err_out arg.
Checking if the err_out is NULL would do the trick too.

It can also be interesting to raise an error message in the interface.
I will propose a patch.

The error is in the internals of the GPU module. Not much related to the python API The crash happens because the offscreen texture has dimensions above the OpenGL limit, and `GPU_offscreen_create` requires a non-NULL `err_out` arg. Checking if the `err_out` is `NULL` would do the trick too. It can also be interesting to raise an error message in the interface. I will propose a patch.

This issue was referenced by 15cfb375a3

This issue was referenced by 15cfb375a39b9d9e35e8c83942edb8f43788427f
Author

Hm. There isn't any way to specify the popup menu size from the Python API though, AFAICT.

In fact, the example code produces a menu that's several times wider than it needs to be, with the majority of the menu being blank space.

Hm. There isn't any way to specify the popup menu size from the Python API though, AFAICT. In fact, the example code produces a menu that's several times wider than it needs to be, with the majority of the menu being blank space.
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Germano Cavalcante was assigned by Pratik Borhade 2022-12-08 12:37:59 +01:00
Member

15cfb375a3 has fixed this, right?
I'll close this report. Please reopen it if problem persists

15cfb375a3 has fixed this, right? I'll close this report. Please reopen it if problem persists
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
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#89782
No description provided.