Skip to content

Commit

Permalink
[lld-macho] Avoid using bump-alloc in TrieBuider
Browse files Browse the repository at this point in the history
The code can be used in multi-threads and the allocator is not thread safe.

fixes PR/54378

Reviewed By: int3, #lld-macho

Differential Revision: https://reviews.llvm.org/D121638
  • Loading branch information
oontvoo authored and int3 committed Mar 14, 2022
1 parent edd3e70 commit e049a87
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lld/MachO/ExportTrie.cpp
Expand Up @@ -145,8 +145,13 @@ void TrieNode::writeTo(uint8_t *buf) const {
}
}

TrieNode::~TrieNode() {
for (TrieNode *node : nodes)
delete node;
}

TrieNode *TrieBuilder::makeNode() {
auto *node = make<TrieNode>();
auto *node = new TrieNode();
nodes.emplace_back(node);
return node;
}
Expand Down
1 change: 1 addition & 0 deletions lld/MachO/ExportTrie.h
Expand Up @@ -22,6 +22,7 @@ class Symbol;

class TrieBuilder {
public:
~TrieBuilder();
void setImageBase(uint64_t addr) { imageBase = addr; }
void addSymbol(const Symbol &sym) { exported.push_back(&sym); }
// Returns the size in bytes of the serialized trie.
Expand Down

0 comments on commit e049a87

Please sign in to comment.