GLTF export crashing upon exceeding allocations
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
See also https://github.com/godotengine/godot/issues/51132.
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.
So is that something that needs to be worked around or can it be fixed?
I changed the COW number to be something above 65535, but need to find the exact place again and check on your input.
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.
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.


We can document this as a existing limitation of godot engine.
Numbers mentioned above: Exceeding 65535 GLTFAccessors