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

"Internal Script Error! - opcode #0 (report please)" when saving a script while a Timer is running in the project (due to live script reloading) #42379

Open
Gustavolucas864 opened this issue Sep 28, 2020 · 7 comments

Comments

@Gustavolucas864
Copy link

Gustavolucas864 commented Sep 28, 2020

error description in debugger:
E 0:01:39.393 call: Condition ' (ip + 5) > _code_size ' is true. Breaking..:
<C++ Source> modules/gdscript/gdscript_function.cpp:447 @ call()
inimigo_ranged_1.gd:30 @ _on_cadencia_tiro_timeout()

Godot version:
3.2.1 stable_win64

OS/device including version:
MX150, GLES2

Issue description:
idk, im working in other script when my game simply crashed...

Steps to reproduce:
idk

Minimal reproduction project:
i will send a .txt with script that crashed (ps. im brazilian, almost whole the words of my variables and functions are in pt-br)

extends KinematicBody2D

var alvo = self #self apenas para n ficar Null e poder dar algum erro
var velocidade = 75 #velocidade com q o inimigo se movimenta
var pode_atirar = true #cadenciador de ataques
var cadencia_ataques = 2.0 #tempo entre cada ataque
export var dano = 10 #dano infligido por esse inimigo
var pre_projetil = preload("res://scenes/projeteis/projetil_inmigo_ranged_1.tscn")

signal morreu


func _ready():
	$"hit_box/CollisionShape2D".disabled = false #ativa a hitbox do inimigo


func _process(delta):
	alvo = self.get_parent().get_node("player") #pega o jogador como alvo
	if (alvo.global_position - self.global_position).length() >= 600: #distancia entre o jogador e o inimigo
		movimento_avanco() #avanca pra cima do jogador
	else:
		tiro() #atira no jogador


func movimento_avanco():
	var direcao_player = (alvo.global_position - self.global_position).normalized()
	move_and_slide(direcao_player * velocidade)


func tiro():
	#it was in this function that the error occurred...
	if pode_atirar: #pode_atirar é uma variavel de controle da cadencia
		pode_atirar = false
		$"AnimationPlayer".play("aviso_ataque_piscada")
		yield($"AnimationPlayer", "animation_finished")
		
		$"AnimationPlayer".play("tiro")
		var mira = alvo.global_position + Vector2(0, -12) #+altura do sprite, pra mirar pro meio da hitbox do jogador
		$"arma".look_at(mira)
		
		var projetil = pre_projetil.instance()
		projetil.vetor = Vector2(cos($"arma".global_rotation), sin($"arma".global_rotation)) #vetor é a direcao que o projetil ira seguir
		projetil.global_rotation = $"arma".global_rotation
		projetil.global_position = $"arma/Position2D".global_position
		self.get_parent().add_child(projetil) 
		
		yield($"AnimationPlayer", "animation_finished") #espera a animacao do tiro terminar
		$"cadencia_tiro".start(cadencia_ataques) #inicia o timer da cadencia


func _on_cadencia_tiro_timeout():
	pode_atirar = true #torna possivel atirar outra vez


func inimigo_acertado():
	#print("inimigo acertado")
	pass

func inimigo_morto():
	#print("inimigo morto")
	
	emit_signal("morreu")
	self.queue_free()
@Demindiro
Copy link
Contributor

So I randomly hit upon this error when I resized a Control and saved the scene while the project was running. I noticed that the error in question happened on a yield call and I was able to reproduce it.

  • Create any scene with any node and attach this script:
extends Node

func _ready():
	while true:
		yield(get_tree().create_timer(1.0), "timeout")
		print("blah")
  • Run the project
  • While the project is running, save the scene again (modifying it is not necessary). You likely will get Internal Script Error! - opcode #0 (report please) or a crash.

I'm guessing it's a use-after-free.

reload-use-after-free.zip

@nonunknown
Copy link
Contributor

nonunknown commented Oct 18, 2021

this happened with me too in 3.4 beta 6 over linux

image

related to the yield too!

@hapenia
Copy link

hapenia commented Jun 25, 2022

This comes back at 3.5 rc4.

@alanenggb
Copy link

on 4.2.dev4 ...

E 0:01:41:0193   root.gd:65 @ _on_context_button_button_up(): Condition ' (ip + 8) > _code_size ' is true. Breaking..:
  <C++ Source>   modules/gdscript/gdscript_vm.cpp:2834 @ call()
  <Stack Trace>  root.gd:65 @ _on_context_button_button_up()

the code is just...

await get_tree().create_timer(5).timeout

@Calinou Calinou changed the title Internal Script Error! - opcode #0 (report please). "Internal Script Error! - opcode #0 (report please)" when saving a script while a Timer is running in the project (due to live script reloading) Dec 15, 2023
@aspragg
Copy link

aspragg commented Dec 15, 2023

I was able to reproduce this with a trivial example.

Create a Sprite2D. Attach this script.
While the game is running, edit the script (for example, change the print("a") to pass) and then save the script.

The next time the time fires you'll get an error. I've found the error can vary. For me, I just got:
Error calling utility function "()": 1

########### script

extends Sprite2D

func _ready():
doStuff()

func _process(delta):
print("a")

func doStuff():
for a in range(1, 30):
await get_tree().create_timer(3).timeout
print("awaited done " + str(a))

@azediawan
Copy link

azediawan commented Mar 3, 2024

same with me but error code is different. If necessary i open new issue post, sorry comments are in Portuguese-BR.
Seems this error occours in line 31 in await get_tree().create_timer(0.5).timeout

error description in debugger:

E 0:05:03:0033   PersonMainScript.gd:31 @ @implicit_new(): Condition ' (ip + 4) > _code_size ' is true. Breaking..:
  <Origem C++>   modules/gdscript/gdscript_vm.cpp:3272 @ call()
  <Rastreamento de Pilha>PersonMainScript.gd:31 @ @implicit_new()

Internal script error! Opcode: 101 (please report).

Godot version:
4.2.1.Stable

error occours in this script

extends Person


func _ready():
	if !is_player:
		NavMeshAgent.velocity_computed.connect(Callable(_on_velocity_computed))
		$SophiaSkin/AnimationTree.active = true

func _process(_delta):
	# adicionando o personagem na lista global caso seja um trabalhador e definindo como nao jogador
	if actual_profession != Profession.PLAYER:
		is_player = false
		CameraNode.current = false
		if !GlobalWorkers.workers_object_list.has(self):
			GlobalWorkers.workers_object_list.append(self)

	else:
		#definindo o personagem como o jogador e habilitando os controles.
		is_player = true
		CameraNode.current = true
		"""
		Habilitando o movimento caso seja o jogador, verificar a classe Movement
		para mais detalhes do porque a fisica estar desabilitada e ativamos a fisica
		"""
	
	set_physics_process(true)
	if NavMeshAgent.is_navigation_finished():
		if work_module.work_spot_is_valid():
			visao.look_at(work_module.initial_work_pos)
			#TODO ajustes para testes remover futuramente!!!
			await get_tree().create_timer(0.5).timeout ## <--------------------------------- ERRORS HAPPENS HERE!!
			if !delivering:
				
				work_module.delivery_work_object()
				print("delivering object")
				delivering = true
			
	pass
#TODO variáveis temporárias
var delivering = false
var moved:bool = false		
func _physics_process(delta):
	
	if not is_on_floor():
		velocity.y -= gravity * delta
		
	if is_player: # este corpo faz o jogador ter permissao para se mover
		process_player_input(delta)
		"""
		necessário fornecer o delta, esta função é herdada da classe movment
		para o movimento funcionar é necessário ativar o physics_process() em uma
		função _ready() ou _process()
		"""
		
	else:#neste bloco o controle do jogador é desabilitado e o personagem se torna um NPC
		move_with_navmesh(delta)
		

on 4.2.dev4 ...

E 0:01:41:0193   root.gd:65 @ _on_context_button_button_up(): Condition ' (ip + 8) > _code_size ' is true. Breaking..:
  <C++ Source>   modules/gdscript/gdscript_vm.cpp:2834 @ call()
  <Stack Trace>  root.gd:65 @ _on_context_button_button_up()

the code is just...

await get_tree().create_timer(5).timeout

@Protowalker
Copy link

This still happens in 4.2.1; it seems to happen whenever you create a timer with get_tree().create_timer and immediately await the timeout signal and then live-reload the script.
this is the line of code that adds the break opcode:

CHECK_SPACE(2);

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

9 participants