mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:07:34 +00:00
LibELF: Warn on self-dlopening libraries while initializing
This commit is contained in:
parent
082a7baa3b
commit
6732fec8b8
3 changed files with 13 additions and 1 deletions
|
@ -299,8 +299,16 @@ static void for_each_unfinished_dependency_of(String const& name, HashTable<Stri
|
||||||
if (!loader.has_value())
|
if (!loader.has_value())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (loader.value()->is_fully_initialized())
|
if (loader.value()->is_fully_relocated()) {
|
||||||
|
if (!loader.value()->is_fully_initialized()) {
|
||||||
|
// If we are ending up here, that possibly means that this library either dlopens itself or a library that depends
|
||||||
|
// on it while running its initializers. Assuming that this is the only funny thing that the library does, there is
|
||||||
|
// a reasonable chance that nothing breaks, so just warn and continue.
|
||||||
|
dbgln("\033[33mWarning:\033[0m Querying for dependencies of '{}' while running its initializers", name);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (seen_names.contains(name))
|
if (seen_names.contains(name))
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -243,6 +243,8 @@ Result<NonnullRefPtr<DynamicObject>, DlErrorMessage> DynamicLoader::load_stage_3
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_fully_relocated = true;
|
||||||
|
|
||||||
return NonnullRefPtr<DynamicObject> { *m_dynamic_object };
|
return NonnullRefPtr<DynamicObject> { *m_dynamic_object };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,7 @@ public:
|
||||||
|
|
||||||
DynamicObject const& dynamic_object() const;
|
DynamicObject const& dynamic_object() const;
|
||||||
|
|
||||||
|
bool is_fully_relocated() const { return m_fully_relocated; }
|
||||||
bool is_fully_initialized() const { return m_fully_initialized; }
|
bool is_fully_initialized() const { return m_fully_initialized; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -161,6 +162,7 @@ private:
|
||||||
|
|
||||||
mutable RefPtr<DynamicObject> m_cached_dynamic_object;
|
mutable RefPtr<DynamicObject> m_cached_dynamic_object;
|
||||||
|
|
||||||
|
bool m_fully_relocated { false };
|
||||||
bool m_fully_initialized { false };
|
bool m_fully_initialized { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue