BGE crashes when LibLoading multiple files asynchronously #42020

Closed
opened 2014-09-30 01:01:26 +02:00 by mobious · 34 comments

System Information
Windows 7 64-bit
Intel HD Graphics 4000

Blender Version
Broken: 2.70 19e627c, 2.71 9337574, 2.72rc eb464ee
Worked: 2.69 r60995

Description
The BGE crashes when attempting to LibLoad 2 files asynchronously at the same time when one of the files contains a high-poly object (about 250,000 faces on my machine).

Files
load.blend - Rendering mode is set to GLSL. Contains an Empty that runs the following script:

import bge

basePath = bge.logic.expandPath('//')
pathList = ['A.blend', 'B.blend']

for path in pathList:
    print('loading:', path)
    bge.logic.LibLoad(basePath + path, 'Scene', async=True)

A.blend - Contains the default Cube.
B.blend (couldn't upload due to file size) - Contains a face that has been subdivide 9 times.

Exact steps for others to reproduce the error
Make sure all the blend files are in the same directory (You'll have to create B.blend yourself since I couldn't upload it. Just delete everything, add the default plane, and subdivide it 9 times). Open load.blend and start the game engine. The crash should occur almost immediately.

Additional Notes

  • It does not matter if the LibLoaded objects are on an active or inactive layer.
  • The order files A.blend and B.blend are loaded in does not matter
  • A.blend must contain an object for the crash to occur.
  • load.blend must be in GLSL mode.
  • The crash does not occur if LibLoad's async argument is False
  • If you make the high-poly object using modifiers, the modifiers must be applied for the crash to occur.
  • I primarily tested the crash on 32-bit versions of Blender. The crash only seems to happen about 50% of the time on 2.71 64-bit Blender. If it did not happen the first time the game engine was started, it would not happen at all unless you completely closed Blender and started it again.
**System Information** Windows 7 64-bit Intel HD Graphics 4000 **Blender Version** Broken: 2.70 19e627c, 2.71 9337574, 2.72rc eb464ee Worked: 2.69 r60995 **Description** The BGE crashes when attempting to LibLoad 2 files asynchronously at the same time when one of the files contains a high-poly object (about 250,000 faces on my machine). **Files** [load.blend](https://archive.blender.org/developer/F113667/load.blend) - Rendering mode is set to GLSL. Contains an Empty that runs the following script: ``` import bge basePath = bge.logic.expandPath('//') pathList = ['A.blend', 'B.blend'] for path in pathList: print('loading:', path) bge.logic.LibLoad(basePath + path, 'Scene', async=True) ``` [A.blend](https://archive.blender.org/developer/F113668/A.blend) - Contains the default Cube. B.blend (couldn't upload due to file size) - Contains a face that has been subdivide 9 times. **Exact steps for others to reproduce the error** Make sure all the blend files are in the same directory (You'll have to create B.blend yourself since I couldn't upload it. Just delete everything, add the default plane, and subdivide it 9 times). Open load.blend and start the game engine. The crash should occur almost immediately. **Additional Notes** - It does not matter if the LibLoaded objects are on an active or inactive layer. - The order files A.blend and B.blend are loaded in does not matter - A.blend must contain an object for the crash to occur. - load.blend must be in GLSL mode. - The crash does not occur if LibLoad's async argument is False - If you make the high-poly object using modifiers, the modifiers must be applied for the crash to occur. - I primarily tested the crash on 32-bit versions of Blender. The crash only seems to happen about 50% of the time on 2.71 64-bit Blender. If it did not happen the first time the game engine was started, it would not happen at all unless you completely closed Blender and started it again.
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @mobious

Added subscriber: @mobious

Added subscriber: @JohnDramor

Added subscriber: @JohnDramor

Yes, for me this bug is actually too.

Yes, for me this bug is actually too.
Member

Added subscriber: @JorgeBernalMartinez

Added subscriber: @JorgeBernalMartinez

Added subscriber: @panzergame

Added subscriber: @panzergame

I can't confirm the bug, for me it works properly.

I can't confirm the bug, for me it works properly.
Author

What Blender version are you using and what are your system specs? I just tested it again on the following:

Blender Version: 2.74, 32-bit (00dfc0)
OS: Windows 8.1 64-bit
Graphics: NVIDIA GeForce GTX 765M
Memory: 8 GB

For me, the crash happens with increasing probability as the number of faces on the plane increases. At 7 subdivisions, the crash happens about 25% of the time, ~50% with 8 subdivisions. At 9 subdivisions, it happens almost every single time.

There have been a few instances where I've been able to run the game engine upwards of 10 times without it crashing even when loading the plane with 9 subdivisions, but closing Blender completely and reopening it without making any changes to the files usually causes it to revert to crashing immediately.

What Blender version are you using and what are your system specs? I just tested it again on the following: Blender Version: 2.74, 32-bit (00dfc0) OS: Windows 8.1 64-bit Graphics: NVIDIA GeForce GTX 765M Memory: 8 GB For me, the crash happens with increasing probability as the number of faces on the plane increases. At 7 subdivisions, the crash happens about 25% of the time, ~50% with 8 subdivisions. At 9 subdivisions, it happens almost every single time. There have been a few instances where I've been able to run the game engine upwards of 10 times without it crashing even when loading the plane with 9 subdivisions, but closing Blender completely and reopening it without making any changes to the files usually causes it to revert to crashing immediately.
Member

I confirm the bug.

Windows 7 64bits, Memory: 16Gb, Graphics: Nvidia Quadro 2000, Blender: 2.74

I confirm the bug. Windows 7 64bits, Memory: 16Gb, Graphics: Nvidia Quadro 2000, Blender: 2.74

Added subscriber: @CaptainAndrew

Added subscriber: @CaptainAndrew

Added subscribers: @Moguri, @dr.sybren

Added subscribers: @Moguri, @dr.sybren

This comment was removed by @panzergame

*This comment was removed by @panzergame*

@mobious: Could you try again with the latest blender version ? (because of changes in 24c94eaf9c)

@mobious: Could you try again with the latest blender version ? (because of changes in 24c94eaf9c)
Author

It still appears to crash on 2.76 bfdb420. The only message I get in the console is:

Error: EXCEPTION_ACCESS_VIOLATION

However, the crash does seem to happen less frequently. Generally, it would only crash about 1/4 of the times I started Blender. If it did not crash the first time the game engine was started, it would almost never crash unless I completely closed Blender and reopened it.

It still appears to crash on 2.76 bfdb420. The only message I get in the console is: ``` Error: EXCEPTION_ACCESS_VIOLATION ``` However, the crash does seem to happen less frequently. Generally, it would only crash about 1/4 of the times I started Blender. If it did not crash the first time the game engine was started, it would almost never crash unless I completely closed Blender and reopened it.

Added subscriber: @you.le

Added subscriber: @you.le

Hi, @mobious: I can't reproduce the bug (windows 10 64 blender 2.76 64 GTX660 8GB RAM). I don't understand. You say that the crash happens "when one of the files contains a high-poly object" and then you say to try with a plane subdivided only 9 times.... Anyway, even with a very high poly plane it doesn't crash on my computer...

Hi, @mobious: I can't reproduce the bug (windows 10 64 blender 2.76 64 GTX660 8GB RAM). I don't understand. You say that the crash happens "when one of the files contains a high-poly object" and then you say to try with a plane subdivided only 9 times.... Anyway, even with a very high poly plane it doesn't crash on my computer...

EDIT: Sorry, I mixed up number of cuts and subdivisions... But I tested with ~400000 faces and it doesn't crash

EDIT: Sorry, I mixed up number of cuts and subdivisions... But I tested with ~400000 faces and it doesn't crash
Author

I've noticed that the crash seems to occur less frequently on newer versions of Blender. On 2.76 with 9 subdivisions (262,144 faces), I've been able to open Blender and run load.blend upwards of 10 times without it crashing even when completely closing Blender between each run. However, it eventually does still crash. Going up to 10 subdivisions (~1 million faces) causes the crash to occur every single time again.

Make sure you're meeting all the other requirements as well (load.blend must be in GLSL mode, A.blend must contain an object, async argument is True, high-poly object is not made using modifiers).

I've noticed that the crash seems to occur less frequently on newer versions of Blender. On 2.76 with 9 subdivisions (262,144 faces), I've been able to open Blender and run load.blend upwards of 10 times without it crashing even when completely closing Blender between each run. However, it eventually does still crash. Going up to 10 subdivisions (~1 million faces) causes the crash to occur every single time again. Make sure you're meeting all the other requirements as well (load.blend must be in GLSL mode, A.blend must contain an object, async argument is True, high-poly object is not made using modifiers).

Added subscriber: @QuentinWenger

Added subscriber: @QuentinWenger

Crashed at first try with 10 divisions on 2.76 release. Using a fresh new build (48f7dd6) makes it work properly for me, I tested about 10x in a row.

Win7 64bits, 8GB, GT650M

@mobious, could you please try with a new buildbot version?

Crashed at first try with 10 divisions on 2.76 release. Using a fresh new build (48f7dd6) makes it work properly for me, I tested about 10x in a row. Win7 64bits, 8GB, GT650M @mobious, could you please try with a new buildbot version?
Author

Crashed immediately multiple times on 2.76 (e43b6e2) with only 9 subdivisions.

Just a reminder: there have been multiple instances where I have tested the problem 10+ times (making sure to completely close Blender between each test) without having a single crash. However, I have yet to test a version where I have not been able to eventually get the crash to occur. It seems the crash is highly dependent on the current state of memory of your machine and how memory gets allocated to Blender.

Crashed immediately multiple times on 2.76 (e43b6e2) with only 9 subdivisions. Just a reminder: there have been multiple instances where I have tested the problem 10+ times (making sure to completely close Blender between each test) without having a single crash. However, I have yet to test a version where I have not been able to eventually get the crash to occur. It seems the crash is highly dependent on the current state of memory of your machine and how memory gets allocated to Blender.

Sorry I meant 4ff6e08.

Well if your sytem runs out of RAM, it seems kinda logical IMHO to have Blender crashing... but maybe I'm wrong?

Anyways, please test with a version at least the one I mentioned two lines above (like by grabing a nightly build tomorrow). Else I don't have any clue... :-/

Sorry I meant 4ff6e08. Well if your sytem runs out of RAM, it seems kinda logical IMHO to have Blender crashing... but maybe I'm wrong? Anyways, please test with a version at least the one I mentioned two lines above (like by grabing a nightly build tomorrow). Else I don't have any clue... :-/
Author

I certainly am not running out of memory. I'm using < 4GB out of 8. If that was the issue, you would expect the crash to occur regardless of whether the async argument was True or False. I only meant that the state the system's memory is in (e.g. what chunks of memory the OS decides to allocate to Blender, how big they are, the order they're in, etc.) likely effects whether the crash will occur or not.

I'll test the version you mentioned when it's up on the build bot site as I don't have an easy way to compile at the moment.

I certainly am not running out of memory. I'm using < 4GB out of 8. If that was the issue, you would expect the crash to occur regardless of whether the async argument was True or False. I only meant that the state the system's memory is in (e.g. what chunks of memory the OS decides to allocate to Blender, how big they are, the order they're in, etc.) likely effects whether the crash will occur or not. I'll test the version you mentioned when it's up on the build bot site as I don't have an easy way to compile at the moment.

Oh okay, effectively I missunderstood, sorry.

Yes, please test it when it's out, and let us know. :-)

Oh okay, effectively I missunderstood, sorry. Yes, please test it when it's out, and let us know. :-)
Author

Tested on ce49c70 since that's the newest build that just came up on the builder. Still crashed with 9 subdivisions.

Tested on ce49c70 since that's the newest build that just came up on the builder. Still crashed with 9 subdivisions.

Added subscriber: @alabd14313

Added subscriber: @alabd14313

I confirm this bug.

I confirm this bug.

Added subscriber: @JacobMerrill-1

Added subscriber: @JacobMerrill-1

Added subscriber: @pgi

Added subscriber: @pgi

Well, for me this is a synchronization issue. Someone is writing to a shared resource that is not guarded. When the value is read, it might be invalid.
Following what happens during the asynchronous load of the scene, I think the source of the problem is the material cache of the scene converter.
In particular, I point my finger at

BL_BlenderDataConversion.cpp, RAS_MaterialBucket *material_from_mesh (851 or so)

That "converter" is the one that comes from the running engine and it reads and writes shared memory locations with no guards.

I did a really awful check with pthread_self() - which should have required synchronization in itself - and on my system, during the test of the proposed file, I've got two different threads calling that function and accessing the same converter pointer.

If anyone else can confirm that converter is not thread safe, that the problem might be this one and the solution... well, problematic, I don't know if adding proper synchronization to the converter type might lead to performance issues.

Well, for me this is a synchronization issue. Someone is writing to a shared resource that is not guarded. When the value is read, it might be invalid. Following what happens during the asynchronous load of the scene, I think the source of the problem is the material cache of the scene converter. In particular, I point my finger at BL_BlenderDataConversion.cpp, RAS_MaterialBucket *material_from_mesh (851 or so) That "converter" is the one that comes from the running engine and it reads and writes shared memory locations with no guards. I did a really awful check with pthread_self() - which should have required synchronization in itself - and on my system, during the test of the proposed file, I've got two different threads calling that function and accessing the same converter pointer. If anyone else can confirm that converter is not thread safe, that the problem might be this one and the solution... well, problematic, I don't know if adding proper synchronization to the converter type might lead to performance issues.

I haven't this bug in UPBGE v0.1.0.

I haven't this bug in UPBGE v0.1.0.
Member

Added subscriber: @Blendify

Added subscriber: @Blendify
Member

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Aaron Carlisle self-assigned this 2019-06-29 02:18:52 +02:00
Member

This task is being closed because the BGE has been removed in Blender 2.8.

This task is being closed because the BGE has been removed in Blender 2.8.
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
11 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#42020
No description provided.