Skip to content

Fix nondeterminism in VALIDATE_AND_RETURN caused by comparing uniniti… #3351

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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2490,6 +2490,14 @@ CompilerType TypeSystemSwiftTypeRef::GetChildCompilerTypeAtIndex(
bool &child_is_base_class, bool &child_is_deref_of_parent,
ValueObject *valobj, uint64_t &language_flags) {
LLDB_SCOPED_TIMER();
child_name = "";
child_byte_size = 0;
child_byte_offset = 0;
child_bitfield_bit_size = 0;
child_bitfield_bit_offset = 0;
child_is_base_class = false;
child_is_deref_of_parent = false;
language_flags = 0;
Comment on lines +2493 to +2500

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these reset here? If this is needed, it's missing a #ifndef NDEBUG

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because we'll validate them against their ast_* counterparts.
They are initialized unconditionally because the initialization has an effect outside of the function (these are passed in by reference), I really don't want to change LLDB's behavior in asserts/non-asserts build.

auto fallback = [&]() -> CompilerType {
LLDB_LOGF(GetLogIfAllCategoriesSet(LIBLLDB_LOG_TYPES),
"Had to engage SwiftASTContext fallback for type %s.",
Expand Down Expand Up @@ -2648,13 +2656,13 @@ CompilerType TypeSystemSwiftTypeRef::GetChildCompilerTypeAtIndex(

#ifndef NDEBUG
std::string ast_child_name;
uint32_t ast_child_byte_size;
int32_t ast_child_byte_offset;
uint32_t ast_child_bitfield_bit_size;
uint32_t ast_child_bitfield_bit_offset;
bool ast_child_is_base_class;
bool ast_child_is_deref_of_parent;
uint64_t ast_language_flags;
uint32_t ast_child_byte_size = 0;
int32_t ast_child_byte_offset = 0;
uint32_t ast_child_bitfield_bit_size = 0;
uint32_t ast_child_bitfield_bit_offset = 0;
bool ast_child_is_base_class = false;
bool ast_child_is_deref_of_parent = false;
uint64_t ast_language_flags = 0;
auto defer = llvm::make_scope_exit([&] {
if (!ModuleList::GetGlobalModuleListProperties()
.GetSwiftValidateTypeSystem())
Expand Down