The problem only happens in gcc.
The core crashes at a certain time when cutting stone.
Thanks to everyone who helped.
//Output GDB
#0 0x080a76eb in std::__invoke_impl<void, void (CHARACTER::* const&)(unsigned int), CHARACTER* const&, unsigned int const&> (
__f=<synthetic pointer>: <optimized out>, __t=<error reading variable>, __f=<synthetic pointer>: <optimized out>, __t=<error reading variable>)
at /usr/local/lib/gcc10/include/c++/bits/invoke.h:70
70 __invoke_impl(__invoke_memfun_deref, _MemFun&& __f, _Tp&& __t,
[Current thread is 1 (LWP 100113)]
(gdb) bt full
#0 0x080a76eb in std::__invoke_impl<void, void (CHARACTER::* const&)(unsigned int), CHARACTER* const&, unsigned int const&> (
__f=<synthetic pointer>: <optimized out>, __t=<error reading variable>, __f=<synthetic pointer>: <optimized out>, __t=<error reading variable>)
at /usr/local/lib/gcc10/include/c++/bits/invoke.h:70
No locals.
#1 std::__invoke<void (CHARACTER::* const&)(unsigned int), CHARACTER* const&, unsigned int const&> (__fn=<synthetic pointer>: <optimized out>)
at /usr/local/lib/gcc10/include/c++/bits/invoke.h:95
No locals.
#2 std::_Mem_fn_base<void (CHARACTER::*)(unsigned int), true>::operator()<CHARACTER* const&, unsigned int const&> (this=<synthetic pointer>)
at /usr/local/lib/gcc10/include/c++/functional:122
No locals.
#3 std::binder2nd<std::_Mem_fn<void (CHARACTER::*)(unsigned int)> >::operator() (__x=<error reading variable>, this=<synthetic pointer>)
at /usr/local/lib/gcc10/include/c++/backward/binders.h:158
No locals.
#4 std::for_each<std::tr1::__detail::_Hashtable_iterator<CHARACTER*, true, false>, std::binder2nd<std::_Mem_fn<void (CHARACTER::*)(unsigned int)> > > (__last=...,
__last=..., __f=..., __first=...) at /usr/local/lib/gcc10/include/c++/bits/stl_algo.h:3844
No locals.
#5 CHARACTER_MANAGER::Update (this=0xbfbfc97c, iPulse=20608) at char_manager.cpp:649
No locals.
#6 0x08144393 in idle () at main.cpp:532
now = {tv_sec = 1663029283, tv_usec = 267220}
passed_pulses = <optimized out>
t = 824307
pta = {tv_sec = 1663029283, tv_usec = 27560}
process_time_count = 6
now = {tv_sec = <optimized out>, tv_usec = <optimized out>}
passed_pulses = <optimized out>
t = <optimized out>
#7 idle () at main.cpp:507
now = {tv_sec = <optimized out>, tv_usec = <optimized out>}
passed_pulses = -1
t = <optimized out>
pta = {tv_sec = 1663029283, tv_usec = 27560}
process_time_count = 6
#8 0x08057d95 in main (argc=1, argv=0xbfbfec90) at main.cpp:264
sectree_manager = {<singleton<SECTREE_MANAGER>> = {_vptr.singleton = 0x83c6bf8 <vtable for SECTREE_MANAGER+8>, static ms_singleton = 0xbfbfbbac},
static current_sectree_version = 768, m_map_pkSectree = {_M_t = {
_M_impl = {<std::allocator<std::_Rb_tree_node<std::pair<unsigned int const, SECTREE_MAP*> > >> = {<__gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<unsigned int const, SECTREE_MAP*> > >> = {<No data fields>}, <No data fields>}, <std::_Rb_tree_key_compare<std::less<unsigned int> >> = {
_M_key_compare = {<std::binary_function<unsigned int, unsigned int, bool>> = {<No data fields>}, <No data fields>}}, <std::_Rb_tree_header> = {
_M_header = {_M_color = std::_S_red, _M_parent = 0x2aaf8ec0, _M_left = 0x2aaf8ec0, _M_right = 0x2aaf8ec0}, _M_node_count = 1}, <No data fields>}}},
m_map_pkArea = {_M_t = {
_M_impl = {<std::allocator<std::_Rb_tree_node<std::pair<int const, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, TAreaInfo, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std--Type <RET> for more, q to quit, c to continue without paging--
//char_manager.cpp
void CHARACTER_MANAGER::Update(int32_t iPulse)
{
BeginPendingDestroy();
{
if (!m_map_pkPCChr.empty())
{
auto callback = !(iPulse % PASSES_PER_SEC(5));
std::for_each(m_map_pkPCChr.begin(), m_map_pkPCChr.end(),
[&callback, &iPulse](const NAME_MAP::value_type& v)
{
auto ch = v.second;
if (ch)
{
if (callback)
{
ch->ResetChatCounter();
ch->CFSM::Update();
}
ch->UpdateCharacter(iPulse);
}
});
}
}
{
//Code causing crash
if (!m_set_pkChrState.empty())
{
#ifdef __GNUC__
std::for_each(m_set_pkChrState.begin(), m_set_pkChrState.end(),
std::bind2nd(std::mem_fn(&CHARACTER::UpdateStateMachine), iPulse));
#else
std::for_each(m_set_pkChrState.begin(), m_set_pkChrState.end(),
[iPulse](LPCHARACTER ch)
{
ch->UpdateStateMachine(iPulse);
});
#endif
}
}
{
auto snapshot = CHARACTER_MANAGER::Instance().GetCharactersByRaceNum(xmas::MOB_SANTA_VNUM);
if (!snapshot.empty())
{
#ifdef __GNUC__
std::for_each(snapshot.begin(), snapshot.end(),
std::bind2nd(std::mem_fn(&CHARACTER::UpdateStateMachine), iPulse));
#else
std::for_each(snapshot.begin(), snapshot.end(),
[iPulse](LPCHARACTER ch)
{
ch->UpdateStateMachine(iPulse);
});
#endif
}
}
if (0 == (iPulse % PASSES_PER_SEC(3600)))
{
for (const auto& it : m_map_dwMobKillCount)
DBManager::instance().SendMoneyLog(MONEY_LOG_MONSTER_KILL, it.first, it.second);
m_map_dwMobKillCount.clear();
}
if (test_server && 0 == (iPulse % PASSES_PER_SEC(60)))
#ifdef __GNUC__
sys_log(0, "CHARACTER COUNT vid %zu pid %zu", m_map_pkChrByVID.size(), m_map_pkChrByPID.size());
#else
sys_log(0, "CHARACTER COUNT vid %Iu pid %Iu", m_map_pkChrByVID.size(), m_map_pkChrByPID.size());
#endif
FlushPendingDestroy();
}
//stdafx.h
#ifdef __GNUC__
#include <tr1/unordered_map>
#include <tr1/unordered_set>
#define TR1_NS std::tr1
#else
#define TR1_NS std
#define isdigit iswdigit
#define isspace iswspace
#endif