Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLTF export crashing upon exceeding allocations #51852

Open
stryker313 opened this issue Aug 18, 2021 · 7 comments
Open

GLTF export crashing upon exceeding allocations #51852

stryker313 opened this issue Aug 18, 2021 · 7 comments

Comments

@stryker313
Copy link

stryker313 commented Aug 18, 2021

Godot version

v3.4.beta3.official

System information

Windows 10 GTX 1060 6gb Intel 4690k

Issue description

GLTF Export crashing upon use. Trying to export with either gltf or glb results in crash and no file.

Steps to reproduce

Open MeshSmall.tscn
Export to any directory you want
Editor Will Crash.

Minimal reproduction project

GLTF EXPORT BUG.zip

@Calinou
Copy link
Member

Calinou commented Aug 18, 2021

See also #51132.

@timothyqiu
Copy link
Member

The scene is too large, it needs 64662 GLTFAccessors. Each GLTFAccessor has two PoolVector, but the actual alloc count does not reach the limit thanks to COW. Later in the export process, each accessor needs to write to an empty PoolVector, so it triggers COW and reaches the 65535 limit.

All memory pool allocations are in use.

And crashes on further null pointer access.

@stryker313
Copy link
Author

So is that something that needs to be worked around or can it be fixed?

@fire
Copy link
Member

fire commented Aug 19, 2021

I changed the COW number to be something above 65535, but need to find the exact place again and check on your input.

@fire
Copy link
Member

fire commented Aug 19, 2021

I don't understand the semantics of this line.

diff --git a/core/pool_vector.h b/core/pool_vector.h
index 83e9fd243a..9d51150e20 100644
--- a/core/pool_vector.h
+++ b/core/pool_vector.h
@@ -38,6 +38,8 @@
 #include "core/safe_refcount.h"
 #include "core/ustring.h"
 
+#include <climits>
+
 struct MemoryPool {
        //avoid accessing these directly, must be public for template access
 
@@ -71,7 +73,7 @@ struct MemoryPool {
        static size_t total_memory;
        static size_t max_memory;
 
-       static void setup(uint32_t p_max_allocs = (1 << 16));
+       static void setup(uint32_t p_max_allocs = UINT_MAX);
        static void cleanup();
 };

Note:

I think last time the number I used experimentally was 1 << 20 instead of UINT_MAX. UINT_MAX crashes.

@fire
Copy link
Member

fire commented Aug 19, 2021

For your character model and using the constant 1 << 20 I was able to export.

There are some other bugs in the gltf2 according to https://github.khronos.org/glTF-Validator/, but here's the output from godot engine.

MeshSmall.zip

image

image

@fire fire changed the title GLTF export crashing upon use GLTF export crashing upon exceeding allocations Sep 29, 2021
@akien-mga akien-mga modified the milestones: 3.4, 3.5 Nov 8, 2021
@fire
Copy link
Member

fire commented Sep 23, 2022

We can document this as a existing limitation of godot engine.

Numbers mentioned above: Exceeding 65535 GLTFAccessors

@YuriSizov YuriSizov modified the milestones: 3.5, 3.x Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants