Skip to content

[lldb][DataFormatters] Adjust retrieval of unordered_map element type #10701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Michael137
Copy link

@Michael137 Michael137 commented May 19, 2025

A user ran into an issue where the libc++ std::unordered_map formatter fails because it can't deduce the element_type. That happens because the node_type is a forwad declaration. And, in fact, dsymutil stripped the definition for std::__1::__hash_node<...> for a particular instantiation. While I'm still unclear whether this is a dsymutil bug, this patch works around said issue by getting the element type from the __table_ member.

Drive-by:

  • Set the m_element_type in Update, which is where the other members are initialized

I don't have a reduced example of this unfortunately. But the crux of the issue is that std::__1::__hash_node<...> only has a forward declaration in the dsym. Then trying to call GetTypeTemplateArgument on that CompilerType fails. And even if the definition was present in the dsym it seems like we're stopped in a context where the CU only had a forward declaration DIE for that type and the node_type never ends up being completed with the definition that lives in another CU.

rdar://150813798

A user ran into an issue where the libc++ std::unordered_map` formatter fails because it can't deduce the `element_type`. That happens because the `node_type` is a forwad declaration. And, in fact, dsymutil stripped the definition for `std::__1::__hash_node<...>` for a particular instantiation. While I'm still unclear whether this is a dsymutil bug, this patch works around said issue by getting the element type from the `__table_` member.

Drive-by:
- Set the `m_element_type` in `Update`, which is where the other members are initialized

I don't have a reduced example of this unfortunately. But the crux of the issue is that `std::__1::__hash_node<...>` only has a forward declaration in the dsym. Then trying to call `GetTypeTemplateArgument` on that `CompilerType` fails. And even if the definition was present in the dsym it seems like we're stopped in a context where the CU only had a forward declaration DIE for that type and the `node_type` never ends up being completed with the definition that lives in another CU.

rdar://150813798
@Michael137 Michael137 requested a review from adrian-prantl May 19, 2025 08:57
@Michael137 Michael137 requested a review from a team as a code owner May 19, 2025 08:57
@adrian-prantl
Copy link

@swift-ci test

@adrian-prantl adrian-prantl merged commit e59566a into swift/release/6.2 May 20, 2025
3 checks passed
@adrian-prantl adrian-prantl deleted the lldb/unordered_map-fwd-decl-fix-to-6.2 branch May 20, 2025 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants