You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using assert from a thread, I expect that the execution would halt the same as when using assert on the main thread. Instead, it forces the caller of assert to return immediately with the "default" value (null for references, false for bool, 0 for int, etc). No error messages are created whatsoever, and execution is not halted. This can cause extremely hard-to-detect bugs that will disappear or transform in a release build. The documentation does not say anything about assert having different functionality on threads other than the main thread, only that you "must be running in the editor," which my assumption was that a new thread is, in fact, still running in the editor.
Steps to reproduce
Create a thread, call a function from inside that thread, call assert(false) from the called function. Then observe that there is no halt for the debugger, there are no error messages, the return value of the called function is the "default" value of the function's return type, and the thread ran to completion despite a failed assert call.
Minimal reproduction project
The following script is enough to reproduce this issue.
extends Node
func _ready() -> void:
var thread = Thread.new()
thread.start(_run_thread)
thread.wait_to_finish()
func _run_thread():
print('thread running...')
var result = _fn()
prints('result:', result)
func _fn() -> int:
assert(false)
return 200
Expected output:
thread running...
result: 200
Actual output:
thread running...
result: 0
The text was updated successfully, but these errors were encountered:
I got a debug break using your code in Godot v4.2.rc (830f29422) - Windows 10.0.22621 - GLES3 (Compatibility) - NVIDIA GeForce RTX 3060 Ti (NVIDIA; 31.0.15.4601) - 12th Gen Intel(R) Core(TM) i7-12700F (20 Threads):
Godot version
v4.1.3.stable.official [f06b6836a]
System information
Godot v4.1.3.stable - Linux Mint 21.1 (Vera) - X11 - Vulkan (Mobile) - dedicated NVIDIA GeForce GTX 1070 (nvidia; 525.125.06) - AMD Ryzen 7 1700 Eight-Core Processor (16 Threads)
Issue description
When using
assert
from a thread, I expect that the execution would halt the same as when usingassert
on the main thread. Instead, it forces the caller ofassert
to return immediately with the "default" value (null
for references,false
forbool
,0
forint
, etc). No error messages are created whatsoever, and execution is not halted. This can cause extremely hard-to-detect bugs that will disappear or transform in a release build. The documentation does not say anything aboutassert
having different functionality on threads other than the main thread, only that you "must be running in the editor," which my assumption was that a new thread is, in fact, still running in the editor.Steps to reproduce
Create a thread, call a function from inside that thread, call
assert(false)
from the called function. Then observe that there is no halt for the debugger, there are no error messages, the return value of the called function is the "default" value of the function's return type, and the thread ran to completion despite a failedassert
call.Minimal reproduction project
The following script is enough to reproduce this issue.
Expected output:
Actual output:
The text was updated successfully, but these errors were encountered: