From 71996ff58a916befd5af6e52eee008777b3f40ef Mon Sep 17 00:00:00 2001 From: proller Date: Wed, 21 Aug 2024 01:49:13 +0000 Subject: [PATCH] fix --- src/CMakeLists.txt | 4 ++ src/activeobjectmgr.h | 2 +- src/mapblock.cpp | 9 ++-- src/mapblock.h | 98 ++++++++++++++++++++++--------------------- util/autotest/auto.pl | 12 +++--- 5 files changed, 65 insertions(+), 60 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9e11ac197..f8b7aa89a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -131,6 +131,10 @@ if(NOT MSVC) message(STATUS "Build with tcmalloc ${TCMALLOC_LIBRARY} ${PROFILER_LIBRARY}") endif() + if(USE_STATIC_LIBRARIES) + list(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES) + endif() + find_library(UNWIND_LIBRARY NAMES unwind) if(UNWIND_LIBRARY) diff --git a/src/activeobjectmgr.h b/src/activeobjectmgr.h index 34db97be6..7b201911c 100644 --- a/src/activeobjectmgr.h +++ b/src/activeobjectmgr.h @@ -101,6 +101,6 @@ class ActiveObjectMgr // removeObject()! //std::map> m_active_objects; - concurrent_shared_unordered_map m_active_objects; + concurrent_unordered_map m_active_objects; std::vector m_active_objects_deleted; }; diff --git a/src/mapblock.cpp b/src/mapblock.cpp index 6a22926f0..d1405745c 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -771,14 +771,13 @@ void MapBlock::deSerializeNetworkSpecific(std::istream &is) #if BUILD_CLIENT MapBlock::mesh_type MapBlock::getLodMesh(int step, bool allow_other) { - - if (m_lod_mesh[step].load(std::memory_order::relaxed) || !allow_other) + if (m_lod_mesh[step] || !allow_other) return m_lod_mesh[step]; for (int inc = 1; inc < 4; ++inc) { - if (step + inc < m_lod_mesh.size() && m_lod_mesh[step + inc].load(std::memory_order::relaxed)) + if (step + inc < m_lod_mesh.size() && m_lod_mesh[step + inc]) return m_lod_mesh[step + inc]; - if (step - inc >= 0 && m_lod_mesh[step - inc].load(std::memory_order::relaxed)) + if (step - inc >= 0 && m_lod_mesh[step - inc]) return m_lod_mesh[step - inc]; } return {}; @@ -799,7 +798,7 @@ void MapBlock::deSerializeNetworkSpecific(std::istream &is) void MapBlock::setFarMesh(const MapBlock::mesh_type &rmesh, uint32_t time) { const auto ms = rmesh->far_step; - if (const auto mesh = m_far_mesh[ms].load(std::memory_order::relaxed)) { + if (const auto mesh = m_far_mesh[ms]) { delete_mesh = mesh; } m_far_mesh[ms] = rmesh; diff --git a/src/mapblock.h b/src/mapblock.h index 5f5df5caf..b9925a4a6 100644 --- a/src/mapblock.h +++ b/src/mapblock.h @@ -26,6 +26,8 @@ along with Freeminer. If not, see . #include #include #include +#include "threading/lock.h" + #include #include "irr_v3d.h" #include "mapnode.h" @@ -36,17 +38,17 @@ along with Freeminer. If not, see . #include "nodetimer.h" #include "modifiedstate.h" #include "util/numeric.h" // getContainerPos -#include "threading/lock.h" #include "settings.h" +class Circuit; +class ServerEnvironment; +struct ActiveABM; + class Map; class NodeMetadataList; class IGameDef; class MapBlockMesh; class VoxelManipulator; -class Circuit; -class ServerEnvironment; -struct ActiveABM; #define BLOCK_TIMESTAMP_UNDEFINED 0xffffffff @@ -148,13 +150,6 @@ class MapBlock //raiseModified(MOD_STATE_WRITE_NEEDED, MOD_REASON_REALLOCATE); } - /* - Flags - */ - - enum modified_light {modified_light_no = 0, modified_light_yes}; - void raiseModified(u32 mod, modified_light light = modified_light_no, bool important = false); - MapNode* getData() { return data; @@ -529,9 +524,17 @@ class MapBlock //fm: + /* + Flags + */ + + enum modified_light {modified_light_no = 0, modified_light_yes}; + void raiseModified(u32 mod, modified_light light = modified_light_no, bool important = false); + + void pushElementsToCircuit(Circuit* circuit); - typedef std::shared_ptr mesh_type; + using mesh_type = std::shared_ptr; #if BUILD_CLIENT // Only on client MapBlock::mesh_type getLodMesh(int step, bool allow_other = false); @@ -540,38 +543,15 @@ class MapBlock void setFarMesh(const MapBlock::mesh_type & rmesh, uint32_t time); std::mutex far_mutex; u32 mesh_requested_timestamp = 0; -#endif -//=== - - - bool storeActiveObject(u16 id); - // clearObject and return removed objects count - u32 clearObjects(); - -private: - /* - Private methods - */ - - void deSerialize_pre22(std::istream &is, u8 version, bool disk); -public: - /* - Public member variables - */ - -#if BUILD_CLIENT // Only on client private: - std::array, LODMESH_STEP_MAX + 1> m_lod_mesh; - std::array, FARMESH_STEP_MAX + 1> m_far_mesh; + std::array m_lod_mesh; + std::array m_far_mesh; MapBlock::mesh_type delete_mesh; public: #endif - NodeMetadataList m_node_metadata; - StaticObjectList m_static_objects; - std::atomic_short heat {0}; std::atomic_short humidity {0}; std::atomic_short heat_add {0}; @@ -604,6 +584,39 @@ class MapBlock std::atomic content_only = CONTENT_IGNORE; u8 content_only_param1 = 0, content_only_param2 = 0; bool analyzeContent(); + std::mutex m_usage_timer_mutex; + + /* + Set to true if changes has been made that make the old lighting + values wrong but the lighting hasn't been actually updated. + + If this is false, lighting is exactly right. + If this is true, lighting might be wrong or right. + */ + + std::atomic_bool m_lighting_expired {false}; + +//=== + + + bool storeActiveObject(u16 id); + // clearObject and return removed objects count + u32 clearObjects(); + +private: + /* + Private methods + */ + + void deSerialize_pre22(std::istream &is, u8 version, bool disk); + +public: + /* + Public member variables + */ + + NodeMetadataList m_node_metadata; + StaticObjectList m_static_objects; static const u32 ystride = MAP_BLOCKSIZE; static const u32 zstride = MAP_BLOCKSIZE * MAP_BLOCKSIZE; @@ -658,16 +671,6 @@ class MapBlock */ std::atomic_bool is_underground = false; - /* - Set to true if changes has been made that make the old lighting - values wrong but the lighting hasn't been actually updated. - - If this is false, lighting is exactly right. - If this is true, lighting might be wrong or right. - */ - - std::atomic_bool m_lighting_expired {false}; - /*! * Each bit indicates if light spreading was finished * in a direction. (Because the neighbor could also be unloaded.) @@ -696,7 +699,6 @@ class MapBlock When the block is accessed, this is set to 0. Map will unload the block when this reaches a timeout. */ - std::mutex m_usage_timer_mutex; float m_usage_timer = 0; /* diff --git a/util/autotest/auto.pl b/util/autotest/auto.pl index 237f30115..33e0d6ec6 100755 --- a/util/autotest/auto.pl +++ b/util/autotest/auto.pl @@ -43,7 +43,7 @@ $0 ---cgroup=10g --address=192.168.0.1 --port=30005 tsan bot # Maybe some features should be disabled for run some sanitizers -$0 ---cmake_clang=1 -DENABLE_WEBSOCKET=0 -DHAVE_TCMALLOC=0 tsan bot +$0 ---cmake_clang=1 -DENABLE_WEBSOCKET=0 -DENABLE_TCMALLOC=0 tsan bot $0 ---cmake_clang=1 -DENABLE_WEBSOCKET=0 asan bot $0 ---cmake_clang=1 -DENABLE_WEBSOCKET=0 ---cmake_leveldb=0 usan bot $0 ---cmake_clang=1 -DENABLE_TIFF=0 gperf bot @@ -178,8 +178,8 @@ () runner => 'nice ', screenshot_dir => 'screenshot.' . $g->{date}, tee => '2>&1 | tee -a ', - tsan_leveldb_fix => 1, - tsan_opengl_fix => 1, + #tsan_leveldb_fix => 1, + #tsan_opengl_fix => 1, valgrind_tools => [qw(memcheck exp-sgcheck exp-dhat cachegrind callgrind massif exp-bbv)], # verbose => 1, vtune_amplifier => '~/intel/vtune_amplifier_xe/bin64/', @@ -451,7 +451,7 @@ () local $config->{make_add} = $config->{make_add}; $config->{make_add} .= " V=1 VERBOSE=1 " if $config->{make_verbose}; #sy qq{nice make -j $config->{makej} $config->{make_add} $config->{tee} $config->{logdir}/autotest.$g->{task_name}.make.log}; - return sytee qq{$config->{make_add} nice cmake --build . -- -j $config->{makej}}, + return sytee qq{$config->{make_add} nice cmake --build . -- -j $config->{makej} $config->{makev}}, qq{$config->{logdir}/autotest.$g->{task_name}.make.log}; }, run_single => sub { @@ -494,7 +494,7 @@ () qq{@_}, $commands->{executable}(), qq{--logfile $config->{logdir}/autotest.$g->{task_name}.game.log}, - options_make([qw(gameid world port config autoexit verbose)]), + options_make($options->{pass}{config} ? () : [qw(gameid world port config autoexit verbose)]), qq{$config->{run_add}}; if ($config->{server_bg}) { @@ -591,7 +591,7 @@ () $g->{keep_config} = 1; $g->{build_names}{san} = 'tsan'; #$config->{options_display} = 'software' if $config->{tsan_opengl_fix} and !$config->{options_display}; - $config->{cmake_leveldb} //= 0 if $config->{tsan_leveldb_fix}; + #$config->{cmake_leveldb} //= 0 if $config->{tsan_leveldb_fix}; $config->{envs}{tsan} = " TSAN_OPTIONS='detect_deadlocks=1 second_deadlock_stack=1 history_size=7'"; #? local $options->{opt}{enable_minimap} = 0; # too unsafe # FATAL: ThreadSanitizer: unexpected memory mapping :