Loading a new file gives crash while rendering in viewport #94041

Closed
opened 2021-12-14 02:33:03 +01:00 by sungreen sungreen · 11 comments

Operating system: Win10, Linux
Graphics card: NVIDIA

Blender Version: 3.10, master)

Short description
Crash appears on loading a new file when viewport render is enabled

Steps to Reproduce

  • Blender Preferences -> Save & Load -> uncheck Load UI
  • Render Cycles
  • Viewport Shading: Rendered
  • File -> New -> General ==> GPUTexture: Texture allocation failed

When data is being accessed gc->texture = 0x0
static GPUTexture *blf_batch_cache_texture_load(void)
{

GlyphCacheBLF *gc = g_batch.glyph_cache;
BLI_assert(gc);
BLI_assert(gc->bitmap_len > 0);
if (gc->bitmap_len > gc->bitmap_len_landed) {
  const int tex_width = GPU_texture_width(gc->texture);

gc->texture = 0x0
gc->bitmap_len = 2022
gc->bitmap_len_landed = 0

Operating system: Win10, Linux Graphics card: NVIDIA Blender Version: 3.10, master) **Short description** Crash appears on loading a new file when viewport render is enabled **Steps to Reproduce** - Blender Preferences -> Save & Load -> uncheck Load UI - Render Cycles - Viewport Shading: Rendered - File -> New -> General ==> GPUTexture: Texture allocation failed When data is being accessed gc->texture = 0x0 static GPUTexture *blf_batch_cache_texture_load(void) { ``` GlyphCacheBLF *gc = g_batch.glyph_cache; BLI_assert(gc); BLI_assert(gc->bitmap_len > 0); ``` ``` if (gc->bitmap_len > gc->bitmap_len_landed) { const int tex_width = GPU_texture_width(gc->texture); ``` gc->texture = 0x0 gc->bitmap_len = 2022 gc->bitmap_len_landed = 0

Added subscriber: @Nikolaysungreen

Added subscriber: @Nikolaysungreen
Member

Added subscriber: @PratikPB2123

Added subscriber: @PratikPB2123
Member

Thanks for the report. Can confirm crash on master (c1f5d8d023c6fdef67efbc6ce2af49e384c9bd98)

Appears to be regression because 2.93.0LTS works fine here

blender.exe         :0x00007FF63CA6EE90  region_draw_emboss
blender.exe         :0x00007FF63CA6A3A0  ED_region_do_draw
blender.exe         :0x00007FF63C4E3310  wm_draw_window_offscreen
blender.exe         :0x00007FF63C4E3160  wm_draw_window
blender.exe         :0x00007FF63C4E2C60  wm_draw_update
blender.exe         :0x00007FF63C4BD330  WM_main
blender.exe         :0x00007FF63C13F190  main
blender.exe         :0x00007FF641657208  __scrt_common_main_seh
KERNEL32.DLL        :0x00007FFBD7637020  BaseThreadInitThunk
ntdll.dll           :0x00007FFBD9622630  RtlUserThreadStart```
Thanks for the report. Can confirm crash on master (`c1f5d8d023c6fdef67efbc6ce2af49e384c9bd98`) Appears to be regression because 2.93.0LTS works fine here ```blender.exe :0x00007FF6414700A0 immVertex2f blender.exe :0x00007FF63CA6EE90 region_draw_emboss blender.exe :0x00007FF63CA6A3A0 ED_region_do_draw blender.exe :0x00007FF63C4E3310 wm_draw_window_offscreen blender.exe :0x00007FF63C4E3160 wm_draw_window blender.exe :0x00007FF63C4E2C60 wm_draw_update blender.exe :0x00007FF63C4BD330 WM_main blender.exe :0x00007FF63C13F190 main blender.exe :0x00007FF641657208 __scrt_common_main_seh KERNEL32.DLL :0x00007FFBD7637020 BaseThreadInitThunk ntdll.dll :0x00007FFBD9622630 RtlUserThreadStart```
Member

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

Changed status from 'Needs Triage' to: 'Confirmed'
Pratik Borhade changed title from GPUTexture: Texture allocation failed to Loading a new file gives crash while rendering in viewport 2021-12-14 10:28:00 +01:00

Added subscriber: @brecht

Added subscriber: @brecht

I suspect something goes wrong with the OpenGL context in BlenderDisplayDriver::gl_context_dispose, causing OpenGL calls to fail aftwards.

I suspect something goes wrong with the OpenGL context in `BlenderDisplayDriver::gl_context_dispose`, causing OpenGL calls to fail aftwards.

Added subscriber: @michael64

Added subscriber: @michael64

Thank you @Nikolaysungreen for the nicely reproducable crash report.
This crash was introduced in 0803119725 so all 2.93 versions still work and 3.0.0 is the first that crashes.
Normally when you switch to cycles-x render view GHOST_CreateOpenGLContext is called as shown in P2669.
When you switch back to solid view GHOST_DisposeOpenGLContext is called.

I pasted a stracktrace of the last GHOST_DisposeOpenGLContext call P2668 and maybe the disposing worked
but I do not see a call of GHOST_CreateOpenGLContext so when the crash happens we might not have a context.

Even without a context the OpenGL functions do not produce something noticable with glGetError().
The first difference after creating a new scene without 'Load UI' is that GLTexture::proxy_check(0)
fails. glTexImage2D(gl_proxy, mip, internal_format, UNPACK2(size), 0, gl_format, gl_type, nullptr)
followed by glGetTexLevelParameteriv(gl_proxy, 0, GL_TEXTURE_WIDTH, &width)
gives a width of 0 for the 16384x1 proxy texture of the glyph cache.
The same sequence before context deletion with the exact same parameters to glTexImage2D worked.

This failed texture proxy check makes GLTexture::init_internal return false and instead of a texture we have NULL
which is dereferenced in blf_batch_cache_texture_load with GPU_texture_width(gc->texture) resulting in a crash.
So far the diagnosis.
Maybe this can be fixed by somehow calling GHOST_CreateOpenGLContext or some ancestor function
in the stacktrace of P2669 when the new scene is generated but I'll leave this to you guys.

Thank you @Nikolaysungreen for the nicely reproducable crash report. This crash was introduced in 0803119725 so all 2.93 versions still work and 3.0.0 is the first that crashes. Normally when you switch to cycles-x render view GHOST_CreateOpenGLContext is called as shown in [P2669](https://archive.blender.org/developer/P2669.txt). When you switch back to solid view GHOST_DisposeOpenGLContext is called. I pasted a stracktrace of the last GHOST_DisposeOpenGLContext call [P2668](https://archive.blender.org/developer/P2668.txt) and maybe the disposing worked but I do not see a call of GHOST_CreateOpenGLContext so when the crash happens we might not have a context. Even without a context the OpenGL functions do not produce something noticable with glGetError(). The first difference after creating a new scene without 'Load UI' is that GLTexture::proxy_check(0) fails. glTexImage2D(gl_proxy, mip, internal_format, UNPACK2(size), 0, gl_format, gl_type, nullptr) followed by glGetTexLevelParameteriv(gl_proxy, 0, GL_TEXTURE_WIDTH, &width) gives a width of 0 for the 16384x1 proxy texture of the glyph cache. The same sequence before context deletion with the exact same parameters to glTexImage2D worked. This failed texture proxy check makes GLTexture::init_internal return false and instead of a texture we have NULL which is dereferenced in blf_batch_cache_texture_load with GPU_texture_width(gc->texture) resulting in a crash. So far the diagnosis. Maybe this can be fixed by somehow calling GHOST_CreateOpenGLContext or some ancestor function in the stacktrace of [P2669](https://archive.blender.org/developer/P2669.txt) when the new scene is generated but I'll leave this to you guys.

Added subscriber: @o6a2

Added subscriber: @o6a2
Sergey Sharybin self-assigned this 2022-01-11 11:25:07 +01:00

This issue was referenced by 7a2b181591

This issue was referenced by 7a2b18159170b91694fd7c64825a699314fae3ca

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' 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
7 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#94041
No description provided.