Skip to content

Commit

Permalink
REMethodDefinition: Fix infinite log spam caused by 0 encoded_offset
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Mar 26, 2024
1 parent b125110 commit a1a241a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions shared/sdk/RETypeDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,9 @@ const char* REMethodDefinition::get_name() const {
return tdb->get_string(name_offset);
}

std::unordered_set<REMethodDefinition*> logged_encoded_0_methods{};
std::shared_mutex logged_encoded_0_methods_mtx{};

void* REMethodDefinition::get_function() const {
#if TDB_VER >= 71
if (this->encoded_offset == 0) {
Expand All @@ -416,6 +419,17 @@ void* REMethodDefinition::get_function() const {
}
}*/

{
std::shared_lock _{ logged_encoded_0_methods_mtx };

if (logged_encoded_0_methods.contains(const_cast<REMethodDefinition*>(this))) {
return nullptr;
}
}

std::unique_lock _{ logged_encoded_0_methods_mtx };
logged_encoded_0_methods.insert(const_cast<REMethodDefinition*>(this));

auto decl_type = this->get_declaring_type();
auto name = decl_type != nullptr ? decl_type->get_full_name() : std::string{"null"};
spdlog::error("[REMethodDefinition::get_function] Encoded offset is 0 (vindex {}) (method: {}.{})", this->get_virtual_index(), name, this->get_name());
Expand Down

0 comments on commit a1a241a

Please sign in to comment.