• Godot Help
  • Can a thread crash without throwing an error in 4.X?

I have a thread that I use to generate AI inputs but when I ran my project one time it sorta just seemed to stop without throwing an error or having the potential of getting stuck in an infinite loop.
So I can't seem to diagnose the issue since there doesn't seem to be anything wrong with my code and I can't seem to isolate the issue yet.

Here's a condensed example of what my code looked like:

func generate_loader_executors_for_all_inactive_entities_in_each_combat_controller_group():
	
	#i call the rest of this function from my thread by awaiting upon it (look at how this works here: https://github.com/godotengine/godot/issues/67174#issuecomment-1698424311)
	if Global_Variables_3D.world.AI_Manager.RUN_AI_WITH_THREADS:
		Logger.info("reattach_to_thread 0")
		await reattach_to_thread()
	
	
	#now go through all combat controller groups (groups of AI entities which work together) and run their loader executor (action) generation functions
	var readied_npc_loader_executors = []
	#this gets printed in my logger.
	Logger.info("Generating loader executors for inactive AI entities...")
	for combat_AI_type_instance in active_combat_AI_type_instances.values():
		for controller_group in combat_AI_type_instance.controller_groups:
			var result = await controller_group.generate_inactive_group_entity_actions()
			
			readied_npc_loader_executors += result
			#this doesn't show up in my logger:
			Logger.info("done con_group: "+str(controller_group))
	
	#call process frame to merge this call back into the main thread (rest of the function is called in the main thread)
	await get_tree().process_frame

And the beginning of the controller_group object function being called starts with a print which isn't shown.

func generate_inactive_group_entity_actions():
	
	var timex = Time.get_ticks_msec()
	#this doesn't show up in my logger either:
	Logger.info("    Generating AI controller group entity actions for group: " + str(self))

The code isn't really that important, the point is that there were some prints which really should've been called but never were, and if something went wrong an error should've been thrown (since 4.x seems to catch errors in threads now). Nothing seemed to happen in the thread after the "Logger.info("Generating loader executors for inactive AI entities...")" line.

Could this be a stability issue caused by me using await calls in a thread? (as that is something that isn't possible without setting Thread.set_thread_safety_checks_enabled(false)) Maybe the issue is caused by me using the same thread over and over again with my reattach_to_thread() system?
Maybe there's currently issues with the master branch (v4.2.dev.custom_build [eb4268ddd]) I've compiled from.
Or could it be something else entirely?

Any ideas on diagnosing this issue would be appreciated.

Did you try to run Godot from a console to see if there is any additional output? I don't know if that is still the case with Godot 4, but in Godot 3 you generally didn't get any error messages from other threads in the editor itself.