DaemonEngine / Daemon

The Dæmon game engine. With some bits of ioq3 and XreaL.
https://unvanquished.net
BSD 3-Clause "New" or "Revised" License
304 stars 60 forks source link

segfault on vid_restart, dll unloading issue affecting Linux too? #584

Open illwieckz opened 2 years ago

illwieckz commented 2 years ago

That may be an Unvanquished issue, but this is close to some other issues like:

and especially this comment: https://github.com/DaemonEngine/Daemon/issues/564#issuecomment-1023785677

and maybe similar to what tried to fix:

On Linux (Ubuntu 20.04 LTS) I built Unvanquished and Dæmon using the 0.53.0/sync branch. I started the game using dll cgame and sgame, then changed screen resolution which triggered a vid_restart. I got this crash:

Default value '' is not correct for cvar 'cgame.cm_forceTriangles': value "" is not of type 'bool' as expected

Warn: Conflicting emoticon images found: emoticons/medstat.crn and emoticons/medstat.crn
Warn: Conflicting emoticon images found: emoticons/leech.crn and emoticons/leech.crn
Warn: Conflicting emoticon images found: emoticons/overmind.crn and emoticons/overmind.crn
Warn: Conflicting emoticon images found: emoticons/trapper.crn and emoticons/trapper.crn
Warn: Conflicting emoticon images found: emoticons/advgranger.crn and emoticons/advgranger.crn
Warn: Conflicting emoticon images found: emoticons/tent.crn and emoticons/tent.crn
Warn: Conflicting emoticon images found: emoticons/rifle.crn and emoticons/rifle.crn
Warn: Conflicting emoticon images found: emoticons/repeater.crn and emoticons/repeater.crn
Warn: Conflicting emoticon images found: emoticons/painsaw.crn and emoticons/painsaw.crn
Warn: Conflicting emoticon images found: emoticons/lcannon.crn and emoticons/lcannon.crn [further messages like this will be suppressed]
Loading Lua interpreter
Loaded font face unifont (from fonts/unifont.ttf).
Loaded font face Roboto (from fonts/Roboto-Bold.ttf).
Loaded font face Roboto (from fonts/Roboto-BoldItalic.ttf).
Loaded font face Roboto (from fonts/Roboto-Italic.ttf).
Loaded font face Roboto (from fonts/Roboto-Regular.ttf).
Loaded font face FontAwesome (from fonts/fontawesome-webfont.ttf).
Loaded font face DejaVu Sans (from fonts/DejaVuSansCondensed.ttf).
Loaded font face Material Icons (from fonts/MaterialIcons-Regular.ttf).
Warn: Crashed with signal 11: Segmentation fault
illwieckz commented 2 years ago

I reproduce it everytime on 0.53.0/sync branch when calling vid_restart while a map is loaded, this time on Ubuntu 21.10 (I'm running dll c/sgame):

#0  CG_TutorialText() at …/Unvanquished/src/cgame/cg_tutorial.cpp:594
#1  CG_Rocket_DrawTutorial() at …/Unvanquished/src/cgame/cg_rocket_draw.cpp:2892
#2  CG_Rocket_UpdateElement(tag = 0x7fff6294aef0 "tutorial") at …/Unvanquished/src/cgame/cg_rocket_draw.cpp:3593
#3  RocketElement::OnUpdate(this = 0x7fff6294aed0) at …/Unvanquished/src/cgame/rocket/rocketElement.h:126
#4  Rml::Core::Element::Update(this = 0x7fff6294aed0, dp_ratio = 1) at …/Unvanquished/libs/RmlUi/Source/Core/Element.cpp:182
#5  Rml::Core::Element::Update(this = 0x7fff617f4e60, dp_ratio = 1) at …/Unvanquished/libs/RmlUi/Source/Core/Element.cpp:203
#6  Rml::Core::Element::Update(this = 0x7fff62859480, dp_ratio = 1) at …/Unvanquished/libs/RmlUi/Source/Core/Element.cpp:203
#7  Rml::Core::Element::Update(this = 0x555564000930, dp_ratio = 1) at …/Unvanquished/libs/RmlUi/Source/Core/Element.cpp:203
#8  Rml::Core::Context::Update(this = 0x7fff61f19da0) at …/Unvanquished/libs/RmlUi/Source/Core/Context.cpp:170
#9  Rocket_Update() at …/Unvanquished/src/cgame/rocket/rocket.cpp:501
#10  CG_Rocket_Frame(state = ) at …/Unvanquished/src/cgame/cg_rocket.cpp:555
#11  operator()(__closure = 0x7fff99cd2877, cs = ) at …/Unvanquished/src/cgame/cg_api.cpp:85
#12  Util::apply_impl<VM::VMHandleSyscall(uint32_t, Util::Reader)::<lambda(cgClientState_t)>, std::tuple<cgClientState_t&&>, 0>(struct {...} &&, std::tuple<cgClientState_t&&> &&, Util::seq<0>)(func = , tuple = ) at …/Daemon/src/common/Util.h:125
#13  Util::apply<VM::VMHandleSyscall(uint32_t, Util::Reader)::<lambda(cgClientState_t)>, std::tuple<cgClientState_t&&> >(struct {...} &&, std::tuple<cgClientState_t&&> &&)(func = , tuple = ) at …/Daemon/src/common/Util.h:130
#14  IPC::detail::HandleMsg<VM::VMHandleSyscall(uint32_t, Util::Reader)::<lambda(cgClientState_t)>, IPC::Message<IPC::Id<0, 9>, cgClientState_t>, IPC::Reply<> >(IPC::Channel &, IPC::SyncMessage<IPC::Message<IPC::Id<0, 9>, cgClientState_t>, IPC::Reply<> >, Util::Reader, struct {...} &&)(channel = , reader = , func = ) at …/Daemon/src/common/IPC/Channel.h:217
#15  IPC::HandleMsg<IPC::SyncMessage<IPC::Message<IPC::Id<0, 9>, cgClientState_t> >, VM::VMHandleSyscall(uint32_t, Util::Reader)::<lambda(cgClientState_t)> >(IPC::Channel &, Util::Reader, struct {...} &&)(channel = , reader = , func = ) at …/Daemon/src/common/IPC/Channel.h:241
#16  VM::VMHandleSyscall(id = 9, reader = ) at …/Unvanquished/src/cgame/cg_api.cpp:84
#17  CommonInit(rootSocket = 33) at …/Daemon/src/shared/VMMain.cpp:66
#18  vmMain(rootSocket = 33) at …/Daemon/src/shared/VMMain.cpp:104
#19  operator()(__closure = 0x555563faca18) at …/Daemon/src/engine/framework/VirtualMachine.cpp:379
#20  std::__invoke_impl<void, VM::CreateInProcessNativeVM(std::pair<IPC::Socket, IPC::Socket>, Str::StringRef, VM::VMBase::InProcessInfo&)::<lambda()> >(std::__invoke_other, struct {...} &&)(__f = ) at /usr/include/c++/11/bits/invoke.h:61
#21  std::__invoke<VM::CreateInProcessNativeVM(std::pair<IPC::Socket, IPC::Socket>, Str::StringRef, VM::VMBase::InProcessInfo&)::<lambda()> >(struct {...} &&)(__fn = ) at /usr/include/c++/11/bits/invoke.h:96
#22  std::thread::_Invoker<std::tuple<VM::CreateInProcessNativeVM(std::pair<IPC::Socket, IPC::Socket>, Str::StringRef, VM::VMBase::InProcessInfo&)::<lambda()> > >::_M_invoke<0>(std::_Index_tuple<0>)(this = 0x555563faca18) at /usr/include/c++/11/bits/std_thread.h:253
#23  std::thread::_Invoker<std::tuple<VM::CreateInProcessNativeVM(std::pair<IPC::Socket, IPC::Socket>, Str::StringRef, VM::VMBase::InProcessInfo&)::<lambda()> > >::operator()(void)(this = 0x555563faca18) at /usr/include/c++/11/bits/std_thread.h:260
#24  std::thread::_State_impl<std::thread::_Invoker<std::tuple<VM::CreateInProcessNativeVM(std::pair<IPC::Socket, IPC::Socket>, Str::StringRef, VM::VMBase::InProcessInfo&)::<lambda()> > > >::_M_run(void)(this = 0x555563faca10) at /usr/include/c++/11/bits/std_thread.h:211
#25  ??() at :0
#0  __libc_recvmsg(flags = 0, msg = 0x7fffffffc710, fd = 32) at ../sysdeps/unix/sysv/linux/recvmsg.c:32
#1  __libc_recvmsg(fd = 32, msg = 0x7fffffffc710, flags = 0) at ../sysdeps/unix/sysv/linux/recvmsg.c:24
#2  NaClReceiveDatagram(handle = 32, message = 0x7fffffffc810, flags = 0) at …/Daemon/libs/nacl/native_client/src/shared/imc/linux/nacl_imc.cc:168
#3  IPC::InternalRecvMsg(handle = 32, reader = ) at …/Daemon/src/common/IPC/Primitives.cpp:380
#4  IPC::Socket::RecvMsg(this = 0x555555e730c0 <cgvm+128>) at …/Daemon/src/common/IPC/Primitives.cpp:470
#5  IPC::Channel::RecvMsg(this = 0x555555e730c0 <cgvm+128>) at …/Daemon/src/common/IPC/Channel.h:111
#6  IPC::Channel::RecvReplyMsg(this = 0x555555e730c0 <cgvm+128>) at …/Daemon/src/common/IPC/Channel.h:121
#7  IPC::detail::SendMsg<VM::VMBase::SendMsg<IPC::SyncMessage<IPC::Message<IPC::Id<(unsigned short)0, (unsigned short)9>, cgClientState_t>, IPC::Reply<> >, cgClientState_t&>(cgClientState_t&)::{lambda(unsigned int, Util::Reader)#1}&, IPC::Message<IPC::Id<(unsigned short)0, (unsigned short)9>, cgClientState_t>, IPC::Reply<>, cgClientState_t&>(IPC::Channel&, VM::VMBase::SendMsg<IPC::SyncMessage<IPC::Message<IPC::Id<(unsigned short)0, (unsigned short)9>, cgClientState_t>, IPC::Reply<> >, cgClientState_t&>(cgClientState_t&)::{lambda(unsigned int, Util::Reader)#1}&, IPC::SyncMessage<IPC::Message<IPC::Id<(unsigned short)0, (unsigned short)9>, cgClientState_t>, IPC::Reply<> >, cgClientState_t&)(channel = , messageHandler = ) at …/Daemon/src/common/IPC/Channel.h:168
#8  IPC::SendMsg<IPC::SyncMessage<IPC::Message<IPC::Id<(unsigned short)0, (unsigned short)9>, cgClientState_t>, IPC::Reply<> >, VM::VMBase::SendMsg<IPC::SyncMessage<IPC::Message<IPC::Id<(unsigned short)0, (unsigned short)9>, cgClientState_t>, IPC::Reply<> >, cgClientState_t&>(cgClientState_t&)::{lambda(unsigned int, Util::Reader)#1}, cgClientState_t&>(IPC::Channel&, VM::VMBase::SendMsg<IPC::SyncMessage<IPC::Message<IPC::Id<(unsigned short)0, (unsigned short)9>, cgClientState_t>, IPC::Reply<> >, cgClientState_t&>(cgClientState_t&)::{lambda(unsigned int, Util::Reader)#1}&&, cgClientState_t&)(channel = , messageHandler = ) at …/Daemon/src/common/IPC/Channel.h:234
#9  VM::VMBase::SendMsg<IPC::SyncMessage<IPC::Message<IPC::Id<(unsigned short)0, (unsigned short)9>, cgClientState_t>, IPC::Reply<> >, cgClientState_t&>(cgClientState_t&)(this = 0x555555e73040 <cgvm>) at …/Daemon/src/engine/framework/VirtualMachine.h:140
#10  CGameVM::CGameRocketFrame(this = 0x555555e73040 <cgvm>) at …/Daemon/src/engine/client/cl_cgame.cpp:1068
#11  SCR_DrawScreenField() at …/Daemon/src/engine/client/cl_scrn.cpp:299
#12  SCR_UpdateScreen() at …/Daemon/src/engine/client/cl_scrn.cpp:339
#13  CL_Frame(msec = 36) at …/Daemon/src/engine/client/cl_main.cpp:2545
#14  Com_Frame() at …/Daemon/src/engine/qcommon/common.cpp:1000
#15  Application::ClientApplication::Frame(this = 0x555555e98280 <Application::GetApp()::app>) at …/Daemon/src/engine/client/ClientApplication.cpp:86
#16  Application::Frame() at …/Daemon/src/engine/framework/Application.cpp:73
#17  main(argc = 49, argv = 0x7fffffffdb48) at …/Daemon/src/engine/framework/System.cpp:729
illwieckz commented 2 years ago

It crashes there:

const char *CG_TutorialText()
{
    playerState_t *ps;
    static char   text[ MAX_TUTORIAL_TEXT ];
    static int    refreshBindings = 0;

    text[ 0 ] = '\0';
    ps = &cg.snap->ps;

    if ( refreshBindings == 0 )
    {
        CG_RefreshBindings();
    }

    refreshBindings = ( refreshBindings + 1 ) % BINDING_REFRESH_INTERVAL;

    if ( !cg.intermissionStarted && !cg.demoPlayback )
    {
→       if ( ps->persistant[ PERS_SPECSTATE ] != SPECTATOR_NOT ||
             ps->pm_flags & PMF_FOLLOW )
slipher commented 2 years ago

Oh that last thing is an issue with the first frame of RML running too early, before some stuff is initialized.