Skip to content
Snippets Groups Projects
Commit b0b5462f authored by Nadav Har'El's avatar Nadav Har'El Committed by Pekka Enberg
Browse files

Elf: Fix also _module_index_list


Fix also concurrent use of _module_index_list (for the per-module TLS).
Use a new mutex _module_index_list mutex to protect it. We could
probably have done something with the RCU instead, but just adding a
new mutex is a lot easier.

Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
parent 8213bf13
No related branches found
No related tags found
No related merge requests found
......@@ -1100,6 +1100,7 @@ init_table get_init(Elf64_Ehdr* header)
ulong program::register_dtv(object* obj)
{
SCOPE_LOCK(_module_index_list_mutex);
auto i = find(_module_index_list, nullptr);
if (i != _module_index_list.end()) {
*i = obj;
......@@ -1112,6 +1113,7 @@ ulong program::register_dtv(object* obj)
void program::free_dtv(object* obj)
{
SCOPE_LOCK(_module_index_list_mutex);
auto i = find(_module_index_list, obj);
assert(i != _module_index_list.end());
*i = nullptr;
......@@ -1119,6 +1121,7 @@ void program::free_dtv(object* obj)
void* program::tls_addr(ulong module)
{
SCOPE_LOCK(_module_index_list_mutex);
return _module_index_list[module]->tls_addr();
}
......
......@@ -475,6 +475,7 @@ private:
// used to determine object::_module_index, so indexes
// are stable even when objects are deleted:
std::vector<object*> _module_index_list;
mutex _module_index_list_mutex;
std::vector<std::string> _search_path;
osv::rcu_ptr<modules_list> _modules_rcu;
modules_list modules_get() const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment