Anyone have information on this non-descript error that leads to crash?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By KnightNine

The error is:

ERROR: Condition "!success" is true.
at: Array::_ref (core\array.cpp:55) - Condition "!success" is true.

And godot crashes shortly after it appears (the error itself isn’t a fatal error):

	================================================================
CrashHandlerException: Program crashed
Engine version: Godot Engine v3.5.1.rc.custom_build (46f4047d2a90e49f29d7098d9aa1eb3ba5a79981)
Dumping the backtrace. Please include this when reporting the bug on: https://github.com/godotengine/godot/issues
[0] CowData<Variant>::_get_size (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\cowdata.h:75)
[1] CowData<Variant>::_get_size (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\cowdata.h:75)
[2] CowData<Variant>::size (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\cowdata.h:126)
[3] Vector<Variant>::size (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\vector.h:86)
[4] Array::size (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\array.cpp:83)
[5] Variant::get (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\variant_op.cpp:2547)
[6] GDScriptFunction::call (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\modules\gdscript\gdscript_function.cpp:579)
[7] GDScriptInstance::call (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\modules\gdscript\gdscript.cpp:1196)
[8] Object::call (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\object.cpp:899)
[9] Object::_call_bind (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\object.cpp:686)
[10] MethodBindVarArg<Object>::call (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\method_bind.h:320)
[11] Object::call (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\object.cpp:918)
[12] Variant::call_ptr (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\variant_call.cpp:1229)
[13] GDScriptFunction::call (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\modules\gdscript\gdscript_function.cpp:1049)
[14] GDScriptInstance::call (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\modules\gdscript\gdscript.cpp:1196)
[15] Object::call (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\object.cpp:899)
[16] Variant::call_ptr (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\variant_call.cpp:1229)
[17] GDScriptFunction::call (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\modules\gdscript\gdscript_function.cpp:1053)
[18] GDScriptFunctionState::resume (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\modules\gdscript\gdscript_function.cpp:1814)
[19] GDScriptFunctionState::_signal_callback (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\modules\gdscript\gdscript_function.cpp:1762)
[20] MethodBindVarArg<GDScriptFunctionState>::call (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\method_bind.h:320)
[21] Object::call (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\object.cpp:918)
[22] Object::emit_signal (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\object.cpp:1230)
[23] Object::emit_signal (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\object.cpp:1286)
[24] SceneTree::iteration (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\scene\main\scene_tree.cpp:555)
[25] Main::iteration (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\main\main.cpp:2267)
[26] OS_Windows::run (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\platform\windows\os_windows.cpp:3543)
[27] widechar_main (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\platform\windows\godot_windows.cpp:176)
[28] _main (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\platform\windows\godot_windows.cpp:198)
[29] main (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\platform\windows\godot_windows.cpp:210)
[30] __scrt_common_main_seh (d:\a01\_work\20\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
[31] BaseThreadInitThunk
-- END OF BACKTRACE --
================================================================

I've spent a day trying to test what is causing it in order to try and replicate it but to no avail and will probably have to keep looking. Looking into `core\array.cpp:55`, where the error condition is triggered, is equally mysterious:
void Array::_ref(const Array &p_from) const {
	ArrayPrivate *_fp = p_from._p;

	ERR_FAIL_COND(!_fp); // should NOT happen.

	if (_fp == _p) {
		return; // whatever it is, nothing to do here move along
	}

	bool success = _fp->refcount.ref();

	ERR_FAIL_COND(!success); // should really not happen either 

	_unref();

	_p = p_from._p;
}

the line that throws the error in question being ERR_FAIL_COND(!success); with the comment “should really not happen either” which means this is probably a condition that wasn’t expected to be possible to trigger.
Though next I’ll probably edit this code so that it is a fatal error and the backtrace might give me some more useful information pointing to what is leading to the error…

Edit: Here is the backtrace except CRASH_COND(!success); is used instead:

================================================================
CrashHandlerException: Program crashed
Engine version: Godot Engine v3.5.1.rc.custom_build (46f4047d2a90e49f29d7098d9aa1eb3ba5a79981)
Dumping the backtrace. Please include this when reporting the bug on: https://github.com/godotengine/godot/issues
[0] Array::_ref (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\array.cpp:56)
[1] Array::_ref (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\array.cpp:56)
[2] Array::Array (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\array.cpp:488)
[3] Variant::reference (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\variant.cpp:940)
[4] Variant::Variant (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\variant.cpp:2502)
[5] GDScriptFunction::call (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\modules\gdscript\gdscript_function.cpp:319)
[6] GDScriptInstance::call (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\modules\gdscript\gdscript.cpp:1196)
[7] Object::call (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\object.cpp:899)
[8] Object::_call_bind (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\object.cpp:686)
[9] MethodBindVarArg<Object>::call (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\method_bind.h:320)
[10] Object::call (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\object.cpp:918)
[11] Variant::call_ptr (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\variant_call.cpp:1229)
[12] GDScriptFunction::call (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\modules\gdscript\gdscript_function.cpp:1049)
[13] GDScriptInstance::call (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\modules\gdscript\gdscript.cpp:1196)
[14] Object::call (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\object.cpp:899)
[15] Variant::call_ptr (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\variant_call.cpp:1229)
[16] GDScriptFunction::call (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\modules\gdscript\gdscript_function.cpp:1053)
[17] GDScriptFunctionState::resume (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\modules\gdscript\gdscript_function.cpp:1814)
[18] GDScriptFunctionState::_signal_callback (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\modules\gdscript\gdscript_function.cpp:1762)
[19] MethodBindVarArg<GDScriptFunctionState>::call (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\method_bind.h:320)
[20] Object::call (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\object.cpp:918)
[21] Object::emit_signal (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\object.cpp:1230)
[22] Object::emit_signal (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\core\object.cpp:1286)
[23] SceneTree::iteration (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\scene\main\scene_tree.cpp:555)
[24] Main::iteration (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\main\main.cpp:2267)
[25] OS_Windows::run (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\platform\windows\os_windows.cpp:3543)
[26] widechar_main (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\platform\windows\godot_windows.cpp:176)
[27] _main (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\platform\windows\godot_windows.cpp:198)
[28] main (C:\Users\USERNAME\Desktop\Godot_v3.1.1-stable_mono_win64\godot master\godot\platform\windows\godot_windows.cpp:210)
[29] __scrt_common_main_seh (d:\a01\_work\20\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
[30] BaseThreadInitThunk
-- END OF BACKTRACE --
================================================================

Other than that, if anyone knows about how this error is potentially triggered, that might help me narrow it down.

Update:
I think I managed to fix it, the cause was using semaphores improperly, allowing for a variable to get overwritten by a separate thread right as I was using it within call()

Sounds like something to look for/bring up on the github issues page

flurick | 2022-10-21 13:02

Yeah but I can only replicate it within my project atm. i need to be able to narrow down the exact “steps to reproduce” in gdscript before it can be fixed.
It’s going on somewhere within my 5000 line long AI algorithm, so I have no real direct control over when it happens (besides entering the same inputs on the characters that I do control) and it is thus really hard to narrow down.

KnightNine | 2022-10-21 18:44

Interesting, I’ve actually been encountering this issue myself. I’ll check my use of mutexes based on your findings, and since I’ve noticed the issue only occurs inside of threads. Oddly enough it happens when reading from a const array on an autoloaded node…

Ianoc | 2023-03-23 06:55

Hey, I know it’s an old issue but I can’t seem to find info anywhere else on this.
I am also experiencing this crash with signal 11 and Condition "!success" is true, and as @Ianoc said it happens with threads and array on an autoload.
Has anyone made progress on this?