GE crashes on exit because of using freed mtfaces from tessfaces #30493

Closed
opened 2012-03-08 21:33:18 +01:00 by Sergey Sharybin · 5 comments

%%%Game Engine is crashing on exit (Esc button) with such backtrace http://www.pasteall.org/29842 if objects are using textures.
This happens because BlenderMaterial objects are storing a link to tface from DM's CD_MTFACE layer (link is setting up in BL_ConvertMesh function) but after initializing all pointers used DM is getting freed and all tesselation data is also getting freed so tface stored in BlenderMaterial points to a freed memory which leads to crash on BGE exit.
Attaching sample file. To reproduce simply hit P button and Esc button (sometimes it's needed to be done several times).%%%

%%%Game Engine is crashing on exit (Esc button) with such backtrace http://www.pasteall.org/29842 if objects are using textures. This happens because BlenderMaterial objects are storing a link to tface from DM's CD_MTFACE layer (link is setting up in BL_ConvertMesh function) but after initializing all pointers used DM is getting freed and all tesselation data is also getting freed so tface stored in BlenderMaterial points to a freed memory which leads to crash on BGE exit. Attaching sample file. To reproduce simply hit P button and Esc button (sometimes it's needed to be done several times).%%%
Author
Owner

Changed status to: 'Open'

Changed status to: 'Open'
Author
Owner

%%%Will try to look into this myself.%%%

%%%Will try to look into this myself.%%%
Author
Owner

%%%Think figured out reason and possible way to fix this issue.
GE converter is creating CDDM from mesh and gets pointers to some arrays like MTFACE and MTFACE. Pointer to MTFaces is stored in Material class which is used in runtime.
Before BMesh it was pretty safe because DM shared the same arrays as base mesh so in fact, GE was using references to arrays from Mesh. After BMesh merge such arrays are more "temporary" -- they're allocating for DM and frees on DM->release() which makes GE to point to freed memory.
Patch attached here makes GE used MTFACE array from base mesh which is exactly the same behavior as in pre-bmesh blender. Other layers aren't switched to be used from Mesh because they seems not be using during runtime, but from pedantic POV (like accessing all data in the same way) it might worth switching them to Mesh's data too. Hopefully order of faces in DM is the same as in tesselated Mesh. At least tests from our svn works smooth now without any crash.
Assigning to Campbell to verify patch and probably find nicer solution.%%%

%%%Think figured out reason and possible way to fix this issue. GE converter is creating CDDM from mesh and gets pointers to some arrays like MTFACE and MTFACE. Pointer to MTFaces is stored in Material class which is used in runtime. Before BMesh it was pretty safe because DM shared the same arrays as base mesh so in fact, GE was using references to arrays from Mesh. After BMesh merge such arrays are more "temporary" -- they're allocating for DM and frees on DM->release() which makes GE to point to freed memory. Patch attached here makes GE used MTFACE array from base mesh which is exactly the same behavior as in pre-bmesh blender. Other layers aren't switched to be used from Mesh because they seems not be using during runtime, but from pedantic POV (like accessing all data in the same way) it might worth switching them to Mesh's data too. Hopefully order of faces in DM is the same as in tesselated Mesh. At least tests from our svn works smooth now without any crash. Assigning to Campbell to verify patch and probably find nicer solution.%%%

%%%fixed r44858. pass NULL to GPU_set_tpage instead, looked through SVN history and cant find a good reason freeing a material should set the OpenGL image state.%%%

%%%fixed r44858. pass NULL to GPU_set_tpage instead, looked through SVN history and cant find a good reason freeing a material should set the OpenGL image state.%%%

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' 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
3 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#30493
No description provided.