Skip to content

Commit

Permalink
Make Symtab::parseTypesNow thread-safe (#1497)
Browse files Browse the repository at this point in the history
There are many places where this is called without a user realizing it.
If they were to call any of those functions in parallel, type parsing
would break.
  • Loading branch information
hainest committed Aug 28, 2023
1 parent bf6e869 commit 7f1e24d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
3 changes: 1 addition & 2 deletions symtabAPI/h/Symtab.h
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,7 @@ class SYMTAB_EXPORT Symtab : public LookupInterface,
bool getExplicitSymtabRefs(std::set<Symtab *> &refs);
std::set<Symtab *> explicitSymtabRefs_{};

//type info valid flag
bool isTypeInfoValid_{false};
std::once_flag types_parsed;

//Relocation sections
bool hasRel_{false};
Expand Down
6 changes: 1 addition & 5 deletions symtabAPI/src/Symtab.C
Original file line number Diff line number Diff line change
Expand Up @@ -2617,11 +2617,7 @@ const Object *Symtab::getObject() const

void Symtab::parseTypesNow()
{
if (isTypeInfoValid_)
return;
isTypeInfoValid_ = true;

parseTypes();
std::call_once(this->types_parsed, [this](){ this->parseTypes(); });
}

SYMTAB_EXPORT Offset Symtab::getElfDynamicOffset()
Expand Down

0 comments on commit 7f1e24d

Please sign in to comment.