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

Segmentation fault when player joins #4373

Open
KeepBotting opened this issue Aug 23, 2019 · 6 comments

Comments

@KeepBotting
Copy link

@KeepBotting KeepBotting commented Aug 23, 2019

Client version: 1.12.2
Server OS: Void
Commit id: 9a1ed26 built at: Fri 16 Aug 10:10:19 UTC 2019

Expected behavior

Current players are undisturbed by new arrivals

Actual behavior

Server segfaults when a new player joins and all players are disconnected

Steps to reproduce the behavior

Unsure if issue is easily reproducible. The only thing I have changed is the difficulty level and added this plugin https://github.com/NiLSPACE/Login

Possible that it could cause the issue?

Here is my log from before the crash

     [20:10:21] Player data file not found for KPC51 (eea4d6b586f332f7b59ba70051b8eb32, offline eea4d6b586f332f7b59ba70051b8eb32 (unused)), will be reset to defaults.
Info [20:10:21] Player KPC51 has joined the game
Info [20:10:24] [branon]: yoooo
Err  [20:10:25]   D:    | Cuberite has encountered an error and needs to close
Err  [20:10:25] Details | SIGSEGV: Segmentation fault
Err  [20:10:25] Cuberite Jenkins clang x64 Release (master) build id: #1032
Err  [20:10:25] from commit id: 9a1ed26893e51aa693bc61602ce9555d04789800 built at: Fri 16 Aug 10:10:19 UTC 2019
Info [20:10:25] Kicking player SilverPikachu1 for "Server shutdown"
Info [20:10:25] Kicking player branon for "Server shutdown"
Info [20:10:25] Kicking player KPC51 for "Server shutdown"
Err  [20:10:25]   D:    | Cuberite has encountered an error and needs to close
Err  [20:10:25] Details | SIGABRT: Server self-terminated due to an internal fault
Err  [20:10:25] Cuberite Jenkins clang x64 Release (master) build id: #1032
Err  [20:10:25] from commit id: 9a1ed26893e51aa693bc61602ce9555d04789800 built at: Fri 16 Aug 10:10:19 UTC 2019
@Seadragon91

This comment has been minimized.

Copy link
Contributor

@Seadragon91 Seadragon91 commented Aug 23, 2019

Did you run reload, when the server was running?

I was able to get a crash, when I used the reload command. The plugin Login uses a hook called OnWorldTick.
The hook function of the code will be called on every world tick. Looking at the code, I guess that the plugin reference that the server in the world tick has can become invalid, when the reload command is run.

This plugin can be used to cause the crash. It can be necessary to run the reload command a few times to get the crash (race condition):

function Initialize(Plugin)
	Plugin:SetName("TestHook")
	Plugin:SetVersion(1)

	cPluginManager:AddHook(cPluginManager.HOOK_WORLD_TICK, function() end)
   
	return true
end

Crash occurs at this method:

bool cPluginManager::CallHookWorldTick(cWorld & a_World, std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec)
{
	return GenericCallHook(HOOK_WORLD_TICK, [&](cPlugin * a_Plugin)
		{
			return a_Plugin->OnWorldTick(a_World, a_Dt, a_LastTickDurationMSec);
		}
	);
}
@KeepBotting

This comment has been minimized.

Copy link
Author

@KeepBotting KeepBotting commented Aug 23, 2019

@Seadragon91

Thanks for your reply. Typically I do reload the server when it is running, yes.

I have spent about an hour trying to provoke the crash by using the "Reload Server" button in the web interface, and logging players in/out, but have not had any luck.

Unauthenticated players are kicked when the server reloads, but this seems like an intentional design feature, and doesn't affect other players.

I added the TestHook plugin you provided but it doesn't seem to make a difference.

Anything else I should check for? I have enabled core dumps and will post the next one I get.

Edit: I have also compiled a release binary myself, and might try using it in the future. I'll keep this issue updated. Any other ideas would be appreciated.

@Seadragon91

This comment has been minimized.

Copy link
Contributor

@Seadragon91 Seadragon91 commented Aug 24, 2019

There is no need to get a core dump. Here is a output of the crash from a debug build:

Thread 9 (Thread 0x7ffff38c0700 (LWP 1101)):
#0  0x0000000000b75a32 in std::__find_if<std::_List_iterator<cPlugin*>, cPluginManager::CallHookWorldTick(cWorld&, std::chrono::duration<long, std::ratio<1l, 1000l> >, std::chrono::duration<long, std::ratio<1l, 1000l> >)::$_66>(std::_List_iterator<cPlugin*>, std::_List_iterator<cPlugin*>, cPluginManager::CallHookWorldTick(cWorld&, std::chrono::duration<long, std::ratio<1l, 1000l> >, std::chrono::duration<long, std::ratio<1l, 1000l> >)::$_66, std::input_iterator_tag) (__first=<Fehler beim Lesen der Variable: Cannot access memory at address 0x10>, __last=, __pred=...)
    at /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_algo.h:150
#1  0x0000000000b759e1 in std::find_if<std::_List_iterator<cPlugin*>, cPluginManager::CallHookWorldTick(cWorld&, std::chrono::duration<long, std::ratio<1l, 1000l> >, std::chrono::duration<long, std::ratio<1l, 1000l> >)::$_66>(std::_List_iterator<cPlugin*>, std::_List_iterator<cPlugin*>, cPluginManager::CallHookWorldTick(cWorld&, std::chrono::duration<long, std::ratio<1l, 1000l> >, std::chrono::duration<long, std::ratio<1l, 1000l> >)::$_66) (__first=, __last=,
    __pred=...) at /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_algo.h:4464
#2  0x0000000000b75945 in std::none_of<std::_List_iterator<cPlugin*>, cPluginManager::CallHookWorldTick(cWorld&, std::chrono::duration<long, std::ratio<1l, 1000l> >, std::chrono::duration<long, std::ratio<1l, 1000l> >)::$_66>(std::_List_iterator<cPlugin*>, std::_List_iterator<cPlugin*>, cPluginManager::CallHookWorldTick(cWorld&, std::chrono::duration<long, std::ratio<1l, 1000l> >, std::chrono::duration<long, std::ratio<1l, 1000l> >)::$_66) (__first=, __last=,
    __pred=...) at /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_algo.h:747
#3  0x0000000000b758c5 in std::any_of<std::_List_iterator<cPlugin*>, cPluginManager::CallHookWorldTick(cWorld&, std::chrono::duration<long, std::ratio<1l, 1000l> >, std::chrono::duration<long, std::ratio<1l, 1000l> >)::$_66>(std::_List_iterator<cPlugin*>, std::_List_iterator<cPlugin*>, cPluginManager::CallHookWorldTick(cWorld&, std::chrono::duration<long, std::ratio<1l, 1000l> >, std::chrono::duration<long, std::ratio<1l, 1000l> >)::$_66) (__first=, __last=,
    __pred=...) at /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_algo.h:765
#4  0x0000000000b6aa7b in cPluginManager::GenericCallHook<cPluginManager::CallHookWorldTick(cWorld&, std::chrono::duration<long, std::ratio<1l, 1000l> >, std::chrono::duration<long, std::ratio<1l, 1000l> >)::$_66>(cPluginManager::PluginHook, cPluginManager::CallHookWorldTick(cWorld&, std::chrono::duration<long, std::ratio<1l, 1000l> >, std::chrono::duration<long, std::ratio<1l, 1000l> >)::$_66) (this=0x3b8f5e0, a_HookName=cPluginManager::HOOK_WORLD_TICK,
    a_HookFunction=...) at /home/lukas/cpp/cuberite/src/Bindings/PluginManager.cpp:230
#5  0x0000000000b6a96d in cPluginManager::CallHookWorldTick (this=0x3b8f5e0, a_World=..., a_Dt=...,
    a_LastTickDurationMSec=...) at /home/lukas/cpp/cuberite/src/Bindings/PluginManager.cpp:1195
#6  0x0000000000a55fe2 in cWorld::Tick (this=0x7ffffcc40010, a_Dt=..., a_LastTickDurationMSec=...)
    at /home/lukas/cpp/cuberite/src/World.cpp:1022
#7  0x0000000000a55ec3 in cWorld::cTickThread::Execute (this=0x7ffffd3916b8)
    at /home/lukas/cpp/cuberite/src/World.cpp:120
#8  0x0000000000aa1137 in cIsThread::DoExecute (this=0x7ffffd3916b8)
    at /home/lukas/cpp/cuberite/src/OSSupport/IsThread.cpp:73
#9  0x0000000000aa27a9 in std::_Mem_fn<void (cIsThread::*)()>::operator()<, void>(cIsThread*) const (
    this=0x52d46e8, __object=0x7ffffd3916b8)
    at /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/functional:601
#10 0x0000000000aa2712 in std::_Bind_simple<std::_Mem_fn<void (cIsThread::*)()> (cIsThread*)>::_M_invoke<0ul>(std::_Index_tuple<0ul>) (this=0x52d46e0)
    at /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/functional:1731
#11 0x0000000000aa26c5 in std::_Bind_simple<std::_Mem_fn<void (cIsThread::*)()> (cIsThread*)>::operator()() (
    this=0x52d46e0) at /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/functional:1720
---Type <return> to continue, or q <return> to quit---
#12 0x0000000000aa2449 in std::thread::_Impl<std::_Bind_simple<std::_Mem_fn<void (cIsThread::*)()> (cIsThread*)> >::_M_run() (this=0x52d46c8) at /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/thread:115
#13 0x00007ffffec81a60 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#14 0x00007ffffe798184 in start_thread (arg=0x7ffff38c0700) at pthread_create.c:312
#15 0x00007ffffe4be03d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

@KeepBotting

This comment has been minimized.

Copy link
Author

@KeepBotting KeepBotting commented Sep 2, 2019

I have not experienced this crash since opening the original issue. Closing for now, will reopen if I am able to reproduce.

@KeepBotting KeepBotting closed this Sep 2, 2019
@Seadragon91

This comment has been minimized.

Copy link
Contributor

@Seadragon91 Seadragon91 commented Sep 26, 2019

This is still a valid issue and should not be closed. It just that it can be difficult to get the crash.

@peterbell10 peterbell10 reopened this Sep 26, 2019
@KeepBotting

This comment has been minimized.

Copy link
Author

@KeepBotting KeepBotting commented Sep 26, 2019

Understood. I have yet to reproduce but will update if/when it happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.