Project keeps crashing when I call dialogue function more than once

Godot Version

V4.3

Question

I’m trying to make my own dialogue system for my game (yippee!) and it’s been going decently well so far. I’ve got a text box on screen, the text scrolls, you can press a button once it’s done to close it, the works. It works perfectly the first time I do, but whenever I do it a second time the game crashes. Godot doesn’t display an error message either, so I really have no clue what’s going on.

Here’s my script for dialogue

extends Node
var Dialogue = false
var Text_Box = preload("res://Scenes/text_box.tscn")
var Dialogue_Section_Done = false
var Text = Text_Box.instantiate()

func _ready() -> void:
	pass 


func _process(delta: float) -> void:
	if Input.is_action_pressed("Leader_Action") and Dialogue_Section_Done == true:
		_end_dialogue()


func _say(Message : String, Sender_File_Path : String):
	Dialogue = true
	var Sender = load(Sender_File_Path)
	add_child(Text)
	var Message_Length = Message.length()
	if Message_Length <= 105:
		_type(Message)
	pass

func _type(Message : String):
	var Text_Section = Text.get_child(1)
	var Char_Index = 0
	var Scroll_Speed = 0.05
	for characters in Message:
		if Message[Char_Index] == ".":
			Scroll_Speed = 0.15
		else:
			Scroll_Speed = 0.05
		await get_tree().create_timer(Scroll_Speed).timeout
		Text_Section.text = Text_Section.text +(Message[Char_Index])
		Char_Index += 1
	Dialogue_Section_Done = true
	Char_Index = 0
	pass

func _end_dialogue():
	Text.queue_free()
	Dialogue = false
	Dialogue_Section_Done = false
	pass

Here’s when a script calls the function

func _process(delta):
	if Input.is_action_just_pressed("Follower_Ability") and GlobalFcNs.Dialogue == false:
		GlobalFcNs._say("Testing... Testing...", File_Path)

Here’s the error message I get

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               Godot [94243]
Path:                  /Volumes/VOLUME/*/Godot 3.app/Contents/MacOS/Godot
Identifier:            org.godotengine.godot
Version:               4.3 (4.3)
Code Type:             X86-64 (Native)
Parent Process:        launchd [1]
User ID:               501

Date/Time:             2024-12-15 19:51:34.0661 -0800
OS Version:            macOS 12.7.6 (21H1320)
Report Version:        12
Anonymous UUID:        3F39E25B-3469-C3AF-E2B5-4C8455A67495

Sleep/Wake UUID:       9E2697BC-E774-49B2-A999-B8F19D58A9B0

Time Awake Since Boot: 2600000 seconds
Time Since Wake:       918 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGABRT)
Exception Codes:       KERN_INVALID_ADDRESS at 0xfffffffffffffff0
Exception Codes:       0x0000000000000001, 0xfffffffffffffff0
Exception Note:        EXC_CORPSE_NOTIFY

VM Region Info: 0xfffffffffffffff0 is not in any region.  Bytes after previous region: 18446603336222531569  
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      VM_ALLOCATE              7fffffeb9000-7fffffeba000 [    4K] r-x/r-x SM=ALI  
--->  
      UNUSED SPACE AT END

Application Specific Information:
abort() called


Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	    0x7ff8197e3fce __pthread_kill + 10
1   libsystem_pthread.dylib       	    0x7ff81981a1ff pthread_kill + 263
2   libsystem_c.dylib             	    0x7ff819765d14 abort + 123
3   Godot                         	       0x1099ede69 0x109107000 + 9334377
4   libsystem_platform.dylib      	    0x7ff81982fdfd _sigtramp + 29
5   ???                           	               0x0 ???
6   Godot                         	       0x10b986219 0x109107000 + 42463769
7   Godot                         	       0x10b986127 0x109107000 + 42463527
8   Godot                         	       0x10b985a67 0x109107000 + 42461799
9   Godot                         	       0x109dcac19 GDScriptFunction::call(GDScriptInstance*, Variant const**, int, Callable::CallError&, GDScriptFunction::CallState*) + 55017
10  Godot                         	       0x109c96e12 GDScriptInstance::callp(StringName const&, Variant const**, int, Callable::CallError&) + 370
11  Godot                         	       0x10db53cfa Object::callp(StringName const&, Variant const**, int, Callable::CallError&) + 154
12  Godot                         	       0x10d893ed8 Variant::callp(StringName const&, Variant const**, int, Variant&, Callable::CallError&) + 264
13  Godot                         	       0x109dc92ee GDScriptFunction::call(GDScriptInstance*, Variant const**, int, Callable::CallError&, GDScriptFunction::CallState*) + 48574
14  Godot                         	       0x109c96e12 GDScriptInstance::callp(StringName const&, Variant const**, int, Callable::CallError&) + 370
15  Godot                         	       0x10b9573c9 Node::_notification(int) + 2633
16  Godot                         	       0x10bfd42e6 0x109107000 + 49074918
17  Godot                         	       0x10db51b2e Object::notification(int, bool) + 62
18  Godot                         	       0x10b9a2615 SceneTree::_process_group(SceneTree::ProcessGroup*, bool) + 405
19  Godot                         	       0x10b9a083f SceneTree::_process(bool) + 879
20  Godot                         	       0x10b9a0eef SceneTree::process(double) + 223
21  Godot                         	       0x109a57ed1 Main::iteration() + 1089
22  Godot                         	       0x1099e8e1a OS_MacOS::run() + 154
23  Godot                         	       0x109a17ef3 main + 387
24  dyld                          	       0x11eb8152e start + 462

Thread 1:
0   libsystem_pthread.dylib       	    0x7ff819815f48 start_wqthread + 0

Thread 2:
0   libsystem_pthread.dylib       	    0x7ff819815f48 start_wqthread + 0

Thread 3:
0   libsystem_pthread.dylib       	    0x7ff819815f48 start_wqthread + 0

Thread 4:
0   libsystem_pthread.dylib       	    0x7ff819815f48 start_wqthread + 0

Thread 5:
0   libsystem_pthread.dylib       	    0x7ff819815f48 start_wqthread + 0

Thread 6:
0   libsystem_pthread.dylib       	    0x7ff819815f48 start_wqthread + 0

Thread 7:
0   libsystem_kernel.dylib        	    0x7ff8197e03aa __psynch_cvwait + 10
1   libsystem_pthread.dylib       	    0x7ff81981aa6f _pthread_cond_wait + 1249
2   libc++.1.dylib                	    0x7ff819778d22 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 18
3   Godot                         	       0x10d73ef1b _IP_ResolverPrivate::_thread_function(void*) + 171
4   Godot                         	       0x10d6055bb Thread::callback(unsigned long long, Thread::Settings const&, void (*)(void*), void*) + 91
5   Godot                         	       0x10d605924 0x109107000 + 72345892
6   libsystem_pthread.dylib       	    0x7ff81981a4e1 _pthread_start + 125
7   libsystem_pthread.dylib       	    0x7ff819815f6b thread_start + 15

Thread 8:
0   libsystem_kernel.dylib        	    0x7ff8197e03aa __psynch_cvwait + 10
1   libsystem_pthread.dylib       	    0x7ff81981aa6f _pthread_cond_wait + 1249
2   libc++.1.dylib                	    0x7ff819778d22 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 18
3   Godot                         	       0x10dba723e WorkerThreadPool::_thread_function(void*) + 270
4   Godot                         	       0x10d6055bb Thread::callback(unsigned long long, Thread::Settings const&, void (*)(void*), void*) + 91
5   Godot                         	       0x10d605924 0x109107000 + 72345892
6   libsystem_pthread.dylib       	    0x7ff81981a4e1 _pthread_start + 125
7   libsystem_pthread.dylib       	    0x7ff819815f6b thread_start + 15

Thread 9:
0   libsystem_kernel.dylib        	    0x7ff8197e03aa __psynch_cvwait + 10
1   libsystem_pthread.dylib       	    0x7ff81981aa6f _pthread_cond_wait + 1249
2   libc++.1.dylib                	    0x7ff819778d22 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 18
3   Godot                         	       0x10dba723e WorkerThreadPool::_thread_function(void*) + 270
4   Godot                         	       0x10d6055bb Thread::callback(unsigned long long, Thread::Settings const&, void (*)(void*), void*) + 91
5   Godot                         	       0x10d605924 0x109107000 + 72345892
6   libsystem_pthread.dylib       	    0x7ff81981a4e1 _pthread_start + 125
7   libsystem_pthread.dylib       	    0x7ff819815f6b thread_start + 15

Thread 10:
0   libsystem_kernel.dylib        	    0x7ff8197e03aa __psynch_cvwait + 10
1   libsystem_pthread.dylib       	    0x7ff81981aa6f _pthread_cond_wait + 1249
2   libc++.1.dylib                	    0x7ff819778d22 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 18
3   Godot                         	       0x10dba723e WorkerThreadPool::_thread_function(void*) + 270
4   Godot                         	       0x10d6055bb Thread::callback(unsigned long long, Thread::Settings const&, void (*)(void*), void*) + 91
5   Godot                         	       0x10d605924 0x109107000 + 72345892
6   libsystem_pthread.dylib       	    0x7ff81981a4e1 _pthread_start + 125
7   libsystem_pthread.dylib       	    0x7ff819815f6b thread_start + 15

Thread 11:
0   libsystem_kernel.dylib        	    0x7ff8197e03aa __psynch_cvwait + 10
1   libsystem_pthread.dylib       	    0x7ff81981aa6f _pthread_cond_wait + 1249
2   libc++.1.dylib                	    0x7ff819778d22 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 18
3   Godot                         	       0x10dba723e WorkerThreadPool::_thread_function(void*) + 270
4   Godot                         	       0x10d6055bb Thread::callback(unsigned long long, Thread::Settings const&, void (*)(void*), void*) + 91
5   Godot                         	       0x10d605924 0x109107000 + 72345892
6   libsystem_pthread.dylib       	    0x7ff81981a4e1 _pthread_start + 125
7   libsystem_pthread.dylib       	    0x7ff819815f6b thread_start + 15

Thread 12:
0   libsystem_kernel.dylib        	    0x7ff8197e027e __semwait_signal + 10
1   libsystem_c.dylib             	    0x7ff8196f4853 nanosleep + 196
2   Godot                         	       0x10a88ffcb OS_Unix::delay_usec(unsigned int) const + 59
3   Godot                         	       0x10d7edeed RemoteDebuggerPeerTCP::_thread_func(void*) + 221
4   Godot                         	       0x10d6055bb Thread::callback(unsigned long long, Thread::Settings const&, void (*)(void*), void*) + 91
5   Godot                         	       0x10d605924 0x109107000 + 72345892
6   libsystem_pthread.dylib       	    0x7ff81981a4e1 _pthread_start + 125
7   libsystem_pthread.dylib       	    0x7ff819815f6b thread_start + 15

Thread 13:: com.apple.NSEventThread
0   libsystem_kernel.dylib        	    0x7ff8197dd93a mach_msg_trap + 10
1   libsystem_kernel.dylib        	    0x7ff8197ddca8 mach_msg + 56
2   CoreFoundation                	    0x7ff8198e129d __CFRunLoopServiceMachPort + 319
3   CoreFoundation                	    0x7ff8198df928 __CFRunLoopRun + 1276
4   CoreFoundation                	    0x7ff8198ded6c CFRunLoopRunSpecific + 562
5   AppKit                        	    0x7ff81c48b572 _NSEventThread + 132
6   libsystem_pthread.dylib       	    0x7ff81981a4e1 _pthread_start + 125
7   libsystem_pthread.dylib       	    0x7ff819815f6b thread_start + 15

Thread 14:: AMCP Logging Spool
0   libsystem_kernel.dylib        	    0x7ff8197dd976 semaphore_wait_trap + 10
1   caulk                         	    0x7ff82231e2e6 caulk::mach::semaphore::wait_or_error() + 16
2   caulk                         	    0x7ff822306148 caulk::concurrent::details::worker_thread::run() + 36
3   caulk                         	    0x7ff822305e0c void* caulk::thread_proxy<std::__1::tuple<caulk::thread::attributes, void (caulk::concurrent::details::worker_thread::*)(), std::__1::tuple<caulk::concurrent::details::worker_thread*> > >(void*) + 41
4   libsystem_pthread.dylib       	    0x7ff81981a4e1 _pthread_start + 125
5   libsystem_pthread.dylib       	    0x7ff819815f6b thread_start + 15

Thread 15:: com.apple.audio.IOThread.client
0   libsystem_kernel.dylib        	    0x7ff8197dd93a mach_msg_trap + 10
1   libsystem_kernel.dylib        	    0x7ff8197ddca8 mach_msg + 56
2   CoreAudio                     	    0x7ff81b461c07 HALB_MachPort::SendSimpleMessageWithSimpleReply(unsigned int, unsigned int, int, int&, bool, unsigned int) + 111
3   CoreAudio                     	    0x7ff81b2ec729 HALC_ProxyIOContext::IOWorkLoop() + 3931
4   CoreAudio                     	    0x7ff81b2eb205 invocation function for block in HALC_ProxyIOContext::HALC_ProxyIOContext(unsigned int, unsigned int) + 63
5   CoreAudio                     	    0x7ff81b4b7616 HALB_IOThread::Entry(void*) + 72
6   libsystem_pthread.dylib       	    0x7ff81981a4e1 _pthread_start + 125
7   libsystem_pthread.dylib       	    0x7ff819815f6b thread_start + 15

Thread 16:
0   libsystem_kernel.dylib        	    0x7ff8197e03aa __psynch_cvwait + 10
1   libsystem_pthread.dylib       	    0x7ff81981aa6f _pthread_cond_wait + 1249
2   libc++.1.dylib                	    0x7ff819778d22 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 18
3   Godot                         	       0x10a54f6ac 0x109107000 + 21268140
4   Godot                         	       0x10a54f51d 0x109107000 + 21267741
5   libsystem_pthread.dylib       	    0x7ff81981a4e1 _pthread_start + 125
6   libsystem_pthread.dylib       	    0x7ff819815f6b thread_start + 15


Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x000000011ebfc600  rcx: 0x00007ff7b6df5238  rdx: 0x0000000000000000
  rdi: 0x0000000000000103  rsi: 0x0000000000000006  rbp: 0x00007ff7b6df5260  rsp: 0x00007ff7b6df5238
   r8: 0x000000010ff72638   r9: 0x0000000000000000  r10: 0x0000000000000000  r11: 0x0000000000000246
  r12: 0x0000000000000103  r13: 0x00007ff7b6df5ac0  r14: 0x0000000000000006  r15: 0x0000000000000016
  rip: 0x00007ff8197e3fce  rfl: 0x0000000000000246  cr2: 0x0000000000000000
  
Logical CPU:     0
Error Code:      0x02000148 
Trap Number:     133

Thread 0 instruction stream:
  31 c9 e8 3f 00 00 00 48-85 c0 74 09 48 8d 05 dc  1..?...H..t.H...
  46 00 00 eb 07 48 8d 05-e3 46 00 00 49 89 07 41  F....H...F..I..A
  b7 01 44 89 f8 48 83 c4-08 5b 41 5e 41 5f 5d c3  ..D..H...[A^A_].
  49 8b 4e 20 48 8b 40 20-48 8b 49 08 48 3b 48 08  I.N H.@ H.I.H;H.
  41 0f 94 c7 eb dc 55 48-89 e5 41 57 41 56 41 55  A.....UH..AWAVAU
  41 54 53 48 83 ec 68 49-89 cc 49 89 fd 48 8b 07  ATSH..hI..I..H..
 [4c]8b 70 f0 49 01 fe 4c-8b 78 f8 48 89 55 d0 48  L.p.I..L.x.H.U.H	<==
  89 95 78 ff ff ff 48 89-7d 80 48 89 75 c8 48 89  ..x...H.}.H.u.H.
  75 88 48 89 4d 90 0f 57-c0 0f 11 45 98 0f 11 45  u.H.M..W...E...E
  a8 0f 11 45 b7 8a 05 4c-84 76 41 84 c0 0f 84 3d  ...E...L.vA....=
  02 00 00 8a 1d 86 64 7c-41 84 db 0f 84 08 01 00  ......d|A.......
  00 4c 3b 7d d0 0f 84 10-01 00 00 49 8b 7f 08 48  .L;}.......I...H

Binary Images:
    0x7ff8197dc000 -     0x7ff819813fff libsystem_kernel.dylib (*) <2fe67e94-4a5e-3506-9e02-502f7270f7ef> /usr/lib/system/libsystem_kernel.dylib
    0x7ff819814000 -     0x7ff81981ffff libsystem_pthread.dylib (*) <5a5f7316-85b7-315e-baf3-76211ee65604> /usr/lib/system/libsystem_pthread.dylib
    0x7ff8196e4000 -     0x7ff81976cfff libsystem_c.dylib (*) <202d7260-ea46-3956-a471-19c9bcf45274> /usr/lib/system/libsystem_c.dylib
       0x109107000 -        0x10fbb0fff org.godotengine.godot (4.3) <27f56adc-28ac-3d00-bc8a-2a457e82a447> /Volumes/VOLUME/*/Godot 3.app/Contents/MacOS/Godot
    0x7ff81982c000 -     0x7ff819835fff libsystem_platform.dylib (*) <81a897b2-8752-3f99-833e-da16ffa9fa58> /usr/lib/system/libsystem_platform.dylib
               0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???
       0x11eb7c000 -        0x11ebe7fff dyld (*) <eea022bb-a6ab-3cd1-8ac1-54ce8cfd3333> /usr/lib/dyld
    0x7ff81976d000 -     0x7ff8197c5fff libc++.1.dylib (*) <a372724f-4642-369b-a01b-28e1f5e83ff1> /usr/lib/libc++.1.dylib
    0x7ff819861000 -     0x7ff819d63fff com.apple.CoreFoundation (6.9) <fdd28505-5456-3c40-a5ba-7890b064db39> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
    0x7ff81c2df000 -     0x7ff81d16efff com.apple.AppKit (6.9) <5dd484cf-ed6a-3633-b42e-6518aeecd5b9> /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
    0x7ff822304000 -     0x7ff822325fff com.apple.audio.caulk (1.0) <f04b5c91-d0ec-33c6-8a81-b80a3ebf827f> /System/Library/PrivateFrameworks/caulk.framework/Versions/A/caulk
    0x7ff81b132000 -     0x7ff81b867fff com.apple.audio.CoreAudio (5.0) <c1c6348f-cee2-3db6-84ea-18655a1fb122> /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=1.0G resident=0K(0%) swapped_out_or_unallocated=1.0G(100%)
Writable regions: Total=704.0M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=704.0M(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Accelerate framework               256K        2 
Activity Tracing                   256K        1 
CG backing stores                  720K        4 
CG image                           148K        4 
ColorSync                          216K       25 
CoreAnimation                       44K        7 
CoreGraphics                        12K        2 
CoreUI image data                  260K        5 
Foundation                          16K        1 
Kernel Alloc Once                    8K        1 
MALLOC                           298.7M      403 
MALLOC guard page                   32K        8 
MALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)
STACK GUARD                       56.1M       17 
Stack                             16.1M       17 
VM_ALLOCATE                        872K       99 
VM_ALLOCATE (reserved)              36K        1         reserved VM address space (unallocated)
__CTF                               756        1 
__DATA                            25.4M      355 
__DATA_CONST                      15.3M      211 
__DATA_DIRTY                       670K      119 
__FONT_DATA                          4K        1 
__LINKEDIT                       659.4M       12 
__OBJC_RO                         82.9M        1 
__OBJC_RW                         3200K        2 
__TEXT                           377.5M      372 
__UNICODE                          592K        1 
dyld private memory               2048K        3 
mapped file                      169.2M       23 
shared memory                      776K       17 
===========                     =======  ======= 
TOTAL                              2.0G     1716 
TOTAL, minus reserved VM space     1.7G     1716 

I don’t know if this is the right place for this sort of thing but I don’t really know what else to do and I am very tired

In this case you need to open a issue on Godot github because this is a bug. The only thing wrong i can imagine here is this:

You attribute a node for the Text variable in the code initialization

But delete the node here and never recreate this again, so in the next use that will be null here:


I recommend you open an issue anyways because the crash is a thing that shouldn’t happen anyways, also if possible you can share an mrp (minimal reproduction project) so i could take a look on this bug (you’ll also need this for the github issue)

Thank you! Fun fact I’m a little bit stupid (seriously tho my tiny ape brain would not have figured this out on my own thank you)

No problem, just mark the question as solved.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.