Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
proller committed Aug 21, 2024
1 parent b0b29f0 commit 71996ff
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 60 deletions.
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/activeobjectmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@ class ActiveObjectMgr
// removeObject()!
//std::map<u16, std::unique_ptr<T>> m_active_objects;

concurrent_shared_unordered_map<u16, TPtr> m_active_objects;
concurrent_unordered_map<u16, TPtr> m_active_objects;
std::vector<TPtr> m_active_objects_deleted;
};
9 changes: 4 additions & 5 deletions src/mapblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
Expand All @@ -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;
Expand Down
98 changes: 50 additions & 48 deletions src/mapblock.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ along with Freeminer. If not, see <http://www.gnu.org/licenses/>.
#include <cstddef>
#include <cstdint>
#include <mutex>
#include "threading/lock.h"

#include <set>
#include "irr_v3d.h"
#include "mapnode.h"
Expand All @@ -36,17 +38,17 @@ along with Freeminer. If not, see <http://www.gnu.org/licenses/>.
#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

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<MapBlockMesh> mesh_type;
using mesh_type = std::shared_ptr<MapBlockMesh>;

#if BUILD_CLIENT // Only on client
MapBlock::mesh_type getLodMesh(int step, bool allow_other = false);
Expand All @@ -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<std::atomic<MapBlock::mesh_type>, LODMESH_STEP_MAX + 1> m_lod_mesh;
std::array<std::atomic<MapBlock::mesh_type>, FARMESH_STEP_MAX + 1> m_far_mesh;
std::array<MapBlock::mesh_type, LODMESH_STEP_MAX + 1> m_lod_mesh;
std::array<MapBlock::mesh_type, FARMESH_STEP_MAX + 1> 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};
Expand Down Expand Up @@ -604,6 +584,39 @@ class MapBlock
std::atomic<content_t> 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;
Expand Down Expand Up @@ -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.)
Expand Down Expand Up @@ -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;

/*
Expand Down
12 changes: 6 additions & 6 deletions util/autotest/auto.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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/',
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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}) {
Expand Down Expand Up @@ -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 :
Expand Down

0 comments on commit 71996ff

Please sign in to comment.