| Issue |
204464
|
| Summary |
[lldb] Qualified-name _expression_ fails with "Multiple internal symbols found" when a namespace name collides with global data symbols
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
qiyao
|
## Summary
When an _expression_ uses a qualified name whose namespace prefix happens to
match the name of two or more *internal* (file-static) data symbols anywhere
in the target, _expression_ evaluation fails with:
```
error: Multiple internal symbols found for '<name>'
```
even though the prefix has already been correctly resolved to a
`NamespaceDecl`. The unrelated data symbols can live in any loaded
module (e.g. a dylib the program links against), so a perfectly valid
_expression_ like `foo::MyFunction()` can fail purely because some other
module exposes globals named `foo`.
This was discovered because `TestAbiTagLookup.py` uses `v1` as an inline
namespace name, and on macOS (Xcode "Rizz" / macOS 27) the dyld shared
cache exposes two unrelated internal data symbols literally named `v1`
(one in `dyld`, one in `libdyld.dylib`). See PR
[#203984](https://github.com/llvm/llvm-project/pull/203984), which renames
the test's namespace to unbreak the suite but explicitly does *not* fix the
underlying bug. this issue tracks that fix.
## Reproducer
The failure is environment-dependent when relying on dyld globals, so PR
#203984 also adds a deterministic, self-contained reproducer at
`lldb/test/API/lang/cpp/namespace_data_symbol_collision/` (marked XFAIL).
It links two non-debug-info objects that each define a file-static data
symbol named `colliding_ns`, while `main.cpp` defines a real namespace
`colliding_ns`:
```cpp
// main.cpp
inline namespace colliding_ns {
template <typename T> int do_thing(T const &t) { return t.mem; }
}
struct S { int mem; };
```
```c
// colliding_a.c / colliding_b.c (built WITHOUT debug info)
static const int colliding_ns __attribute__((used)) = 1; // and = 2 in b
```
Evaluating the qualified call then fails:
```
(lldb) expr colliding_ns::do_thing(S{.mem = 6})
error: Multiple internal symbols found for 'colliding_ns'
```
Expected: namespace resolution succeeds and the call returns `6`.
> Note: two internal symbols are required to hit the *hard error*. A single
> internal collision is silently absorbed (`FindBestGlobalDataSymbol`
> returns it as a candidate without erroring), so the symptom only surfaces
> when ≥2 modules contribute a same-named internal symbol — which is exactly
> the macOS dyld/libdyld case.
/cc @bulbazord @Teemperor
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs