-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Editor crashes when saving built-in script with a non empty last line #85093
Comments
I can't reproduce the issue on Linux, for me it saves properly, adding a newline at the end of the script (as Godot follows the Unix convention of terminating files with a newline character). Might behave differently on Windows. Can you reproduce the bug systematically, and does this happen with 4.1.3-stable? |
Can't reproduce it on Windows. The new line is added and the script is saved. Not entirely sure if it would be related, since all it does is add a line break to the string edited by the text editor. But we also can't disable this behavior via settings, so we can't test if it's a factor or not. But I would guess that the crash happens for some other reason. |
I'm sorry, I should have done more testing before writing the issue, it is consistent, it happens every single time on 4.2.rc1 with the project I was working on but actually only in certain scenes. And I do not have it in newly created scenes. Also I ran the console version and when crashing it printed
And I think I ended up cornering the bug, it seems an AnimationPlayer Node is causing the crash (which was in a lot of the files I was working, which made me think it was always happening), maybe because it references deleted nodes. But it is somehow linked with the ending line of built-in scripts being empty or not. The scene was originally created using 4.1-stable, the conversions may also have introduced the problem. Here is the scene file : |
Actually I think this time I really got it, It works even in new projects.
|
@Mohamed-Kr This is perfect, I can reproduce it now! I also noticed that when you first try to keyframe a property, you get this logged: And here's the crash stack:
cc @TokageItLab |
Do note that having a script without an empty line at the end does seem to be critical to reproduce the issue. Which is weird and may imply it's not purely an animation issue. Maybe some race condition? |
So I've looked further into this. There is indeed a conflict of two operations trying to do the same thing. When we call Both times we collect animation data
But the second time happens inside of the first time. So first the first pass collects it, does other things, and eventually triggers saving of external data. This triggers the second pass, which collects the animation data, does its things, end eventually successfully ends. This gives control back to the first pass, but I guess the animation data has already expired. We don't immediately do anything with it, but it crashes when trying to free the memory. The reason why we trigger the second pass is indeed hidden in the fact that we add a new empty line at the end of the script, which makes the script to be marked as unsaved. This doesn't happen under other circumstances. We can approach this a few different ways, though it's strange to me what happens to the animation data that we collect. Guarding against this would probably be the best option. |
I don't remember touching the script itself in relation to the AnimationMixer implementation. If I had to say, I remember putting a check to not copy the script when generating the dummy player, but it probably has nothing to do with it. But I think it might be related to the problem of trying to memdelete the null pointer that @KoBeWi and I have been discussing on ContributorsChat and #84942 (comment). |
Yes, this seems to be it. |
Godot version
4.2.rc1
System information
Godot v4.2.rc1 - Windows 10.0.22621 - GLES3 (Compatibility) - Intel(R) Iris(R) Plus Graphics (Intel Corporation; 27.20.100.9621) - Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz (8 Threads)
Issue description
The editor crashes when saving a scene that contains a built-in script with a non empty last line.
The save always seem to take place anyway with an empty line added to the problematic script.
Steps to reproduce
Minimal reproduction project
N/A
The text was updated successfully, but these errors were encountered: