Skip to content

Conversation

@allevato
Copy link
Member

@allevato allevato commented Mar 7, 2025

This is a companion to swiftlang/swift#78812 (but can be merged independently first). I'm trying to fix a subtle bug in the tests where null pointers were silently being let through, which traps in certain environments with more strict pointer enforcement.

In that change, Node::deepEquals now asserts if either of the arguments is null. The rationale is that the caller should be responsible for what happens in this situation; i.e., is a null pointer a demangling failure that should proceed no further, or an expected "no node" state? These LLDB tests appear to treat null as the latter situation, so I've updated them to state that explicitly.

This is a companion to swiftlang/swift#78812
(but can be merged independently first). I'm trying to fix a subtle
bug in the tests where null pointers were silently being let through,
which traps in certain environments with more strict pointer
enforcement.

In that change, `Node::deepEquals` now asserts if either of the
arguments is null. The rationale is that the caller should be
responsible for what happens in this situation; i.e., is a null
pointer a demangling failure that should proceed no further, or an
expected "no node" state? These LLDB tests appear to treat null as
the latter situation, so I've updated them to state that explicitly.
@allevato allevato requested a review from a team as a code owner March 7, 2025 14:14
@allevato
Copy link
Member Author

allevato commented Mar 7, 2025

@adrian-prantl Does this look reasonable to you? I was surprised to see nulls getting into this function but perhaps it's intentional based on which types are being tested.

@allevato
Copy link
Member Author

Friendly ping: @adrian-prantl @JDevlieghere any concerns with this change?

@DmT021
Copy link

DmT021 commented Mar 12, 2025

Accidentally stumbled across this PR, but I'd suggest considering moving NullSafeNodeDeepEquals to lldb/source/Plugins/TypeSystem/Swift/SwiftDemangle.h. It'll likely be useful in other places (TypeSystemSwiftTypeRef, SwiftLanguageRuntimeDynamicTypeResolution, etc).

Also, as a side note, I understand the point you've made in swiftlang/swift#78812 about NodePointer being a currency type. Still, at the same time, I'm afraid that this will not be the last case of accidental use of this function with potentially NULL arguments. It'd be nice if the compiler enforced null-safety, or we could at least provide a safe overload as a hint to a programmer to be cautious.

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