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

Fix regression with C# build editor crash due to EditorHelpHighlighter #89861

Merged

Conversation

dalexeev
Copy link
Member

@dalexeev dalexeev commented Mar 24, 2024

The crash is caused by double free.

Thread 1 "godot.linuxbsd." received signal SIGABRT, Aborted.

#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x00007ffff7c428e6 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x00007ffff7c268b7 in __GI_abort () at ./stdlib/abort.c:79
#5  0x00007ffff7c27750 in __libc_message (fmt=fmt@entry=0x7ffff7dc3b34 "%s\n") at ../sysdeps/posix/libc_fatal.c:150
#6  0x00007ffff7ca3ce7 in malloc_printerr (str=str@entry=0x7ffff7dc6a40 "double free or corruption (!prev)") at ./malloc/malloc.c:5765
#7  0x00007ffff7ca5cdc in _int_free_merge_chunk (av=0x7ffff7dfeca0 <main_arena>, p=0x55555d673b80, size=880) at ./malloc/malloc.c:4672
#8  0x00007ffff7ca5fd9 in _int_free (av=0x7ffff7dfeca0 <main_arena>, p=<optimized out>, have_lock=<optimized out>) at ./malloc/malloc.c:4639
#9  0x00007ffff7ca8873 in __GI___libc_free (mem=<optimized out>) at ./malloc/malloc.c:3391
#10 0x0000555556de22ca in memdelete<Script> (p_class=0x55555d673ba0) at ./core/os/memory.h:119
#11 memdelete<Script> (p_class=0x55555d673ba0) at ./core/os/memory.h:111
#12 Ref<Script>::unref (this=0x55556fa21ad0) at ./core/object/ref_counted.h:210
#13 Ref<Script>::~Ref (this=0x55556fa21ad0, __in_chrg=<optimized out>) at ./core/object/ref_counted.h:223
#14 EditorHelpHighlighter::~EditorHelpHighlighter (this=0x55556fa21a50, __in_chrg=<optimized out>) at editor/editor_help.cpp:3579
#15 0x0000555556de4959 in memdelete<EditorHelpHighlighter> (p_class=0x55556fa21a50) at ./core/os/memory.h:111
#16 EditorHelpHighlighter::free_singleton () at editor/editor_help.cpp:3442
#17 0x0000555556eadadc in EditorNode::~EditorNode (this=0x55555fbcbb90, __in_chrg=<optimized out>) at editor/editor_node.cpp:7439
#18 0x0000555557e30772 in memdelete<Node> (p_class=0x55555fbcbb90) at ./core/os/memory.h:111
#19 memdelete<Node> (p_class=0x55555fbcbb90) at ./core/os/memory.h:111
#20 Node::_notification (this=0x55555fb5b950, p_notification=<optimized out>) at scene/main/node.cpp:235
#21 0x000055555a1e831e in Object::_predelete (this=0x55555fb5b950) at core/object/object.cpp:199
#22 predelete_handler (p_object=p_object@entry=0x55555fb5b950) at core/object/object.cpp:2135
#23 0x0000555557e7274f in memdelete<Window> (p_class=0x55555fb5b950) at ./core/os/memory.h:111
#24 SceneTree::finalize (this=0x55555fb5b440) at scene/main/scene_tree.cpp:630
#25 0x0000555555aff38c in main (argc=<optimized out>, argv=0x7fffffffe418) at platform/linuxbsd/godot_linuxbsd.cpp:86

I'm guessing this is related to SelfList:

CSharpScript::CSharpScript() {
_clear();
#ifdef DEBUG_ENABLED
{
MutexLock lock(CSharpLanguage::get_singleton()->script_instances_mutex);
CSharpLanguage::get_singleton()->script_list.add(&script_list);
}
#endif
}
CSharpScript::~CSharpScript() {
#ifdef DEBUG_ENABLED
{
MutexLock lock(CSharpLanguage::get_singleton()->script_instances_mutex);
CSharpLanguage::get_singleton()->script_list.remove(&script_list);
}
#endif
if (GDMonoCache::godot_api_cache_updated) {
GDMonoCache::managed_callbacks.ScriptManagerBridge_RemoveScriptBridge(this);
}
}

To save the C# highlighting, I added a hack to EditorStandardSyntaxHighlighter. In the future we should refactor, the highlighter should probably not depend on Script and TextEdit.

@paulloz
Copy link
Member

paulloz commented Mar 24, 2024

Not 100% certain, but those feel related too? I'm quite positive for the first one, a little less so the other two.

@akien-mga akien-mga merged commit fe25b18 into godotengine:master Apr 5, 2024
16 checks passed
@dalexeev dalexeev deleted the editor-help-fix-csharp-crash branch April 5, 2024 10:28
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants