-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[lldb] Only get child if m_storage and m_element_type is valid #163077
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
Conversation
This causes a crash because lldb-dap will check the first child to see if it is array like to lazy load the children.
@llvm/pr-subscribers-lldb Author: Ebuka Ezike (da-viper) ChangesThis causes a crash because lldb-dap will check the first child to see if it is array like to lazy load the children. Full diff: https://github.com/llvm/llvm-project/pull/163077.diff 1 Files Affected:
diff --git a/lldb/source/Plugins/Language/CPlusPlus/MsvcStlAtomic.cpp b/lldb/source/Plugins/Language/CPlusPlus/MsvcStlAtomic.cpp
index 3ec324577ac76..372b6c7afdd78 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/MsvcStlAtomic.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/MsvcStlAtomic.cpp
@@ -50,7 +50,7 @@ llvm::Expected<uint32_t> lldb_private::formatters::
lldb::ValueObjectSP
lldb_private::formatters::MsvcStlAtomicSyntheticFrontEnd::GetChildAtIndex(
uint32_t idx) {
- if (idx == 0)
+ if (idx == 0 && m_storage && m_element_type.IsValid())
return m_storage->Cast(m_element_type)->Clone(ConstString("Value"));
return nullptr;
}
|
Not sure the best way to test this, As it only happens because llvm-project/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp Lines 1865 to 1868 in 2a96d19
maybe on |
The changes to the atomic synthetic children look good to me.
You could create a mock atomic like namespace std {
template <typename T>
struct atomic {
int foo;
};
} |
By "loaded" do you mean it's actually trying to use it? That seems wrong. I thought the formatters have a callback to check that we are on MSVC vs. Linux. Maybe that check isn't working? |
Ah we don't have such a callback because libstdc++ doesn't have a |
Maybe the MSVC formatters (even ones that don't have a libstdc++ counterpart) should be check if the type is an actually valid MSVC type. Like we do for the common STL formatters. @Nerixyz ? |
They should. This patch is still good to avoid crashes with other STLs and potential changes to MS' one. Should the MSVC check happen in this PR or in another one? |
Separate PR would make sense! |
…163176) From #163077 (comment): Currently, `std::atomic<T>` will always use the MSVC STL synthetic children and summary. When inspecting types from other STLs, the output would not show any children. This PR adds a check that `std::atomic` contains `_Storage` to be classified as coming from MSVC's STL.
…children (#163176) From llvm/llvm-project#163077 (comment): Currently, `std::atomic<T>` will always use the MSVC STL synthetic children and summary. When inspecting types from other STLs, the output would not show any children. This PR adds a check that `std::atomic` contains `_Storage` to be classified as coming from MSVC's STL.
It seems #163176 covers the test case. |
…lvm#163176) From llvm#163077 (comment): Currently, `std::atomic<T>` will always use the MSVC STL synthetic children and summary. When inspecting types from other STLs, the output would not show any children. This PR adds a check that `std::atomic` contains `_Storage` to be classified as coming from MSVC's STL.
Technically it doesnt. This patch adds a null check for the case where we picked the MSVC formatter but the layout wasnt the one that the MSVC formatter expected. A test-case for this would look like the simulator test that @Nerixyz added in the patch you linked. But we would need a dummy Not saying such a test is all that interesting since MSVC STL is unlikely to change in that way and the null check is good to have anyway. But it would've been good to wait for another round of reviews/approvals before merging |
This causes a crash because lldb-dap will check the first child to see if it is array like to lazy load the children.