私はいくつかの小さなオンラインゲームを実行しており、しばらくの間にサーバークラッシュがあります。私はSIGSEGVの原因を見つけることができません。 gdbは私をその機能に連れて行きます:find関数を使用するときにstd :: mapでSIGSEGVを取得する
制限付きメモリ領域にアクセスしようとしないようにしてもよろしいですか?私は、同時にスレッドがいくつかの要素にしようとしてはいけないし、コードにミューテックスを追加しました
(gdb) bt full
#0 0x000000000054503c in std::less<unsigned int>::operator()(unsigned int const&, unsigned int const&) const()
No symbol table info available.
#1 0x0000000000740dca in std::_Rb_tree<unsigned int, std::pair<unsigned int const, int>, std::_Select1st<std::pair<unsigned int const, int> >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, int> > >::_M_lower_bound(std::_Rb_tree_node<std::pair<unsigned int const, int> > const*, std::_Rb_tree_node<std::pair<unsigned int const, int> > const*, unsigned int const&) const()
No symbol table info available.
#2 0x000000000073e145 in std::_Rb_tree<unsigned int, std::pair<unsigned int const, int>, std::_Select1st<std::pair<unsigned int const, int> >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, int> > >::find(unsigned int const&) const()
No symbol table info available.
#3 0x000000000073c46f in std::map<unsigned int, int, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, int> > >::find(unsigned int const&) const()
No symbol table info available.
#4 0x000000000072dfa2 in Player::getStorageValue(unsigned int, int&) const()
No symbol table info available.
#5 0x00000000006b2890 in LuaScriptInterface::luaPlayerGetStorageValue(lua_State*)()
bool Player::getStorageValue(const uint32_t key, int32_t& value) const
{
std::lock_guard<std::mutex> lockClass(mutex_gp13);
auto it = storageMap.find(key);
if (it == storageMap.end()) {
value = -1;
return false;
}
value = it->second;
return true;
}
私はそれがすべきかかわら:
そしてHERESに私のgdbのログ私の問題を解決しましたが、今日はそのgdbログと同じSIGSEGVを持っていました。
編集: マップに書き込む関数にmutexを置かなかったことがわかりました。私は今これで試してみるつもりです。
地図が壊れているようです。ここのコードは大丈夫です。 –