godotengine / godotengine/godot
Memory leak and crash when creating custom shapes for ShapeCast
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
Reproducible in 4.3 stable and 4.2.2 stable
### System information
Godot v4.3.stable - macOS 14.6.1 - GLES3 (Compatibility) - Apple M1 Pro - Apple M1 Pro (8 Threads)
### Issue description
Attempting to create a Convex or Concave PolygonShape2D makes Godot freeze, until a memory error appears when reaching 86 GB of memory used for Godot, which keeps going up if the app is not forced to quit.
This doesn't occur when selecting any of the premade shapes.
The only error I found on the logs that may be related are the following:
```
ERROR: 1 RID allocations of type 'P12GodotShape2D' were leaked at exit.
USER WARNING: 1 RID of type "CanvasItem" was leaked.
at: _free_rids (servers/rendering/renderer_canvas_cull.cpp:2483)
USER WARNING: ObjectDB instances leaked at exit (run with --verbose for details).
at: cleanup (core/object/object.cpp:2284)
USER ERROR: 1 resources still in use at exit (run with --verbose for details).
at: clear (core/io/resource.cpp:604)
```
### Steps to reproduce
1. Create a ShapeCast2D
2. For the Shape field, click a Convex or Concave PolygonShape2D
I tested this on an empty project and was able to reproduce just as in my other projects
### Minimal reproduction project (MRP)
N/A
Contributor guide
Research direction
Reproduce the freeze in an empty Godot project by assigning a Convex or Concave PolygonShape2D to a ShapeCast2D, then run with verbose logging to investigate the reported leaks. Begin with the mentioned cleanup paths in servers/rendering/renderer_canvas_cull.cpp, core/object/object.cpp, and core/io/resource.cpp. Done means custom shapes no longer cause runaway memory use or a crash.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, godot
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100