<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - duplicate symbol when loading the same framework via macho::parseLCLinkerOption"
href="https://bugs.llvm.org/show_bug.cgi?id=52133">52133</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>duplicate symbol when loading the same framework via macho::parseLCLinkerOption
</td>
</tr>
<tr>
<th>Product</th>
<td>lld
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Macintosh
</td>
</tr>
<tr>
<th>OS</th>
<td>MacOS X
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>MachO
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>zhongkaining.paxos@bytedance.com
</td>
</tr>
<tr>
<th>CC</th>
<td>gkm@fb.com, jezreel@gmail.com, llvm-bugs@lists.llvm.org, smeenai@fb.com
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=25347" name="attach_25347" title="As this screenshot shows, the two StringRef instances were supposed to be equal (and they are equal at least before the string data of RHS was released)">attachment 25347</a> <a href="attachment.cgi?id=25347&action=edit" title="As this screenshot shows, the two StringRef instances were supposed to be equal (and they are equal at least before the string data of RHS was released)">[details]</a></span>
As this screenshot shows, the two StringRef instances were supposed to be equal
(and they are equal at least before the string data of RHS was released)
When loading a framework twice from two object file via
macho::parseLCLinkerOption, loadedArchives is not aware that this framework was
already loaded, and thus report "error: duplicate symbol".
My guess is that this is because when lld was loading this framework for the
first time, the string representing the path of the framework was released when
lld exits from macho::parseLCLinkerOption, so the StringRef instance
representing this framework in DenseMap's bucket becomes an empty string
instead of the path of the framework. Therefore, when lld was trying to load
this framework for the second time, it finds the bucket for the same key
representing the path of the framework, only to find that the key in the bucket
is no longer equal to the key used to look up now, because the data in
StringRef instance was already released.
In line 631 in DenseMap.h, it tries to compare two StringRef instance to see if
they are equal by compare their data. However, since the data of the StringRef
instance stored in the bucket was released, this comparison function will
return false, thus causing loadedArchives cannot recognize that this framework
was already loaded.
I assume this can be solved by letting the bucket in DenseMap own the string
instance using std::string instead of llvm::StringRef, but this could costs
lots of space since the string instance is much larger than StringRef. Any
advice on this so I can fix this issue?</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>