-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
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
Undefined behavior when set_script on itself #16943
Comments
It's natural that the current function will finish execution, or at least try to. I'm not sure why the reference is lost so soon to make it crash. |
I am not sure how to fix this or whether it's worth fixing, up to you @vnen |
If it couldn't be fixed (expected because it's probably not intended to be used this way) then I'd appreciate some documentation/warning messages discouraging users to do so. |
We can add a warning (or even an error) if you try this, similar to the error you get when you use |
Testing MRP on linux mint 18.3: 3.0: Error immediately, but no crash on nearly every run. 3.1: same as 3.0, but game crashes on most runs. 3.2, 3.2.1: crashes on every run. No output in editor but terminal outputs 3.2.2, 3.2.3.rc3: same as 3.0 without script.is_null() error. Backtrace from a crash in 3.2.2 (Calinou godot-3.2.2-debug-linux-gcc5.4) (crashed less than every 1/100 runs)
tl;dr: MRP does still crash Godot, sometimes. Using A.gd extends Node
func _ready():
call_deferred("set_script", preload("res://B.gd"))
call_deferred("set_process", true)
print("A.gd: My final message.") B.gd extends Node
func _process(dt):
print("B.gd: process") produces good output (sample from 3.2.2):
Tested with 3.0, 3.1, 3.2, 3.2.1, 3.2.2 (50 runs), 3.2.3.rc3, all successful. Small quirk: in recent versions where you don't need to |
Godot/OS version:
92ece2e | Antergos x86_64
Issue description:
Adding these scripts after
set_script
print("some string")
set_process(true)
Expected: old script stops execution when set_script on itself / Not crash / some docs about it
Happened:
print
prints Null,set_process
crashes the gameSteps to reproduce:
A.gd
B.gd
Minimal reproduction project:
SetScript.zip
The text was updated successfully, but these errors were encountered: