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

Crash with doctest on attempting to debug the editor when compiling with tests=yes #40666

Closed
Xrayez opened this issue Jul 24, 2020 · 10 comments · Fixed by #40730
Closed

Crash with doctest on attempting to debug the editor when compiling with tests=yes #40666

Xrayez opened this issue Jul 24, 2020 · 10 comments · Fixed by #40730

Comments

@Xrayez
Copy link
Contributor

Xrayez commented Jul 24, 2020

Godot version:
4.0-dev 5287124

OS/device including version:
Windows 10
target=debug, bits=64
MSVC version 14.2, arch amd64
Happens in both VS2017 and VS2019.

Issue description:
Call stack from VS Code:

ntdll.dll!00007ffb47c1b810() (Unknown Source:0)
godot.windows.tools.64.4.exe!_malloc_base(unsigned __int64 size) Line 34 (c:\Users\Xrayez\AppData\Local\Programs\Microsoft VS Code\minkernel\crts\ucrt\src\appcrt\heap\malloc_base.cpp:34)
godot.windows.tools.64.4.exe!operator new(unsigned __int64 size) Line 35 (d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\heap\new_scalar.cpp:35)
godot.windows.tools.64.4.exe!std::ios_base::_Init() Line 476 (c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\xiosbase:476)
godot.windows.tools.64.4.exe!std::basic_ios<char,std::char_traits<char> >::init(std::basic_streambuf<char,std::char_traits<char> > * _Strbuf, bool _Isstd) Line 148 (c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\ios:148)
godot.windows.tools.64.4.exe!std::basic_ostream<char,std::char_traits<char> >::basic_ostream<char,std::char_traits<char> >(std::basic_streambuf<char,std::char_traits<char> > * _Strbuf, bool _Isstd) Line 33 (c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\ostream:33)
godot.windows.tools.64.4.exe!std::basic_ostringstream<char,std::char_traits<char>,std::allocator<char> >::basic_ostringstream<char,std::char_traits<char>,std::allocator<char> >(int _Mode) Line 453 (c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\sstream:453)
godot.windows.tools.64.4.exe!doctest::detail::`dynamic initializer for 'g_oss''() Line 2866 (d:\src\godot\thirdparty\doctest\doctest.h:2866)
godot.windows.tools.64.4.exe!__dyn_tls_init(void * __formal, unsigned long dwReason, void * __formal) Line 99 (d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\tls\tlsdyn.cpp:99)
ntdll.dll!00007ffb47c05021() (Unknown Source:0)
ntdll.dll!00007ffb47c05103() (Unknown Source:0)
ntdll.dll!00007ffb47c02ebc() (Unknown Source:0)
ntdll.dll!00007ffb47c51875() (Unknown Source:0)
ntdll.dll!00007ffb47c517d3() (Unknown Source:0)
ntdll.dll!00007ffb47c5177e() (Unknown Source:0)

Screenshot from Visual Studio:

2020-07-24

Running the editor or tests without debugger works fine.

Steps to reproduce:
Compile the engine with scons tests=yes: #40696.

I'm using the C++ extension for VSCode to debug Godot with Visual Studio Windows debugger, with the configuration file similar to this:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Godot: Editor",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "${workspaceFolder}/bin/godot.windows.tools.64.4.exe",
            "args": ["--editor", "--path", "D:/bin/godot/projects/test"],
            "stopAtEntry": false,
            "environment": [],
            "externalConsole": true,
        },
    ]
}

Minimal reproduction project:
Happens even on project manager startup.

@Xrayez Xrayez changed the title Crash with doctest on attempting to debug the editor Crash with doctest on attempting to debug the editor using VS Code Jul 24, 2020
@Xrayez Xrayez changed the title Crash with doctest on attempting to debug the editor using VS Code Crash with doctest on attempting to debug the editor using Visual Studio debugger Jul 24, 2020
@RevoluPowered
Copy link
Contributor

As discussed in IRC full rebuild fixes this issue

@Xrayez Xrayez closed this as completed Jul 24, 2020
@Xrayez Xrayez changed the title Crash with doctest on attempting to debug the editor using Visual Studio debugger Crash with doctest on attempting to debug the editor Jul 24, 2020
@Xrayez
Copy link
Contributor Author

Xrayez commented Jul 24, 2020

Reopening because it now happens sporadically. 👀

When I do manage to startup the editor, I get either #40667 or #40654 on exiting Godot while debugging. I then stop the debugging forcefully, and when try to debug again, I get this crash. Stopping the debugging again and now can launch the editor, and the same steps can be repeated.

That's with full engine rebuild as described above: git clean -xdf.

@Xrayez Xrayez reopened this Jul 24, 2020
@RevoluPowered
Copy link
Contributor

RevoluPowered commented Jul 24, 2020

I will look into this now and see if this happens on OSX too, under the same conditions.

@RevoluPowered
Copy link
Contributor

RevoluPowered commented Jul 24, 2020

If not will try out MSVC/vscode on windows

@RevoluPowered
Copy link
Contributor

Some good news OSX cannot reproduce this, so indeed it's isolated to VSCode on windows with MSVC.

@Xrayez
Copy link
Contributor Author

Xrayez commented Jul 24, 2020

When compiling with bits=32:

godot.windows.tools.32.exe!abort() Line 77 (c:\Users\Xrayez\AppData\Local\Programs\Microsoft VS Code\minkernel\crts\ucrt\src\appcrt\startup\abort.cpp:77)
godot.windows.tools.32.exe!__InternalCxxFrameHandler<__FrameHandler3>(EHExceptionRecord * pExcept, EHRegistrationNode * pRN, _CONTEXT * pContext, void * pDC, const _s_FuncInfo * pFuncInfo, int CatchDepth, EHRegistrationNode * pMarkerRN, unsigned char recursive) Line 256 (d:\agent\_work\4\s\src\vctools\crt\vcruntime\src\eh\frame.cpp:256)
godot.windows.tools.32.exe!__CxxFrameHandler3(EHExceptionRecord * pExcept, EHRegistrationNode * pRN, void * pContext, void * pDC) Line 268 (d:\agent\_work\4\s\src\vctools\crt\vcruntime\src\eh\i386\trnsctrl.cpp:268)
ntdll.dll!76f48e72() (Unknown Source:0)
ntdll.dll![Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll] (Unknown Source:0)
ntdll.dll!76f48e44() (Unknown Source:0)
ntdll.dll!76f2820f() (Unknown Source:0)
ntdll.dll!76f342d6() (Unknown Source:0)
ntdll.dll!76f48e72() (Unknown Source:0)
ntdll.dll!76f48e44() (Unknown Source:0)
ntdll.dll!76f2820f() (Unknown Source:0)
ntdll.dll!76f342d6() (Unknown Source:0)
godot.windows.tools.32.exe!__dyn_tls_init(void * __formal, unsigned long dwReason, void * __formal) Line 99 (d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\tls\tlsdyn.cpp:99)
ntdll.dll!76f31de6() (Unknown Source:0)
ntdll.dll!76ef5608() (Unknown Source:0)
ntdll.dll!76f04654() (Unknown Source:0)
ntdll.dll!76ef589e() (Unknown Source:0)
ntdll.dll!76f11d9b() (Unknown Source:0)
ntdll.dll!76f11cc1() (Unknown Source:0)

I get this trace rarely, like need to start debug 10 times, but mostly I get the call stack as described in the issue above.

@Xrayez
Copy link
Contributor Author

Xrayez commented Jul 25, 2020

@RevoluPowered still getting crashes with #40681, but I got curious whether removing all DOCTEST_THREAD_LOCAL occurrences in doctest.h could help, and it does, I cannot reproduce this anymore... I'm also able to run tests without issues: .\bin\godot.windows.tools.64.exe --test -s

@Xrayez
Copy link
Contributor Author

Xrayez commented Jul 25, 2020

Same crash if compiled under VS2017 or VS2019 toolchains.

Found very similar issue regarding thread_local crashes:

tinycthread/tinycthread#44

https://en.wikipedia.org/wiki/Thread-local_storage#Windows_implementation

@RevoluPowered
Copy link
Contributor

doctest/doctest#401

@bruvzg
Copy link
Member

bruvzg commented Jul 25, 2020

BTW, have anyone tested Mingw build? thread_local seems to be part of C-runtime not C++, Mingw is probably using the same default Windows UCRT, and Godot is linking runtime statically to avoid dependency on libstdc++.

@Xrayez Xrayez changed the title Crash with doctest on attempting to debug the editor Crash with doctest on attempting to debug the editor with tests=yes Jul 25, 2020
@Xrayez Xrayez changed the title Crash with doctest on attempting to debug the editor with tests=yes Crash with doctest on attempting to debug the editor when compiling with tests=yes Jul 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment