-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix a couple references to nullptr #63666
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
@swift-ci please test |
I've been running the tests again locally and there's more of these. I'll add those in tomorrow. |
Certain actions do not initialize `ASTContext`, eg. `TypecheckModuleFromInterface`. But `performAction` was always grabbing a `ASTContext&`. With `_GLIBCXX_ASSERTIONS` and `_LIBCPP_ENABLE_ASSERTIONS` now enabled in an asserts build, this hits an assert in `unique_ptr::operator*` that checks for a null deref.
swift-ide-test was creating a `CompilerInstance` and then passing its `ASTContext` along for printing diagnostics. But `CompilerInstance` only has an `ASTContext` if it has been initialized, which it hasn't. Change the print to only print diagnostics when an `ASTContext` is actually available.
249a6a7
to
fd4f51a
Compare
@swift-ci please test |
These two along with #63612 should fix these asserts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
taking a reference to a
nullptr
The fact that that wasn't crashing is really something else.
Thanks, I hate it. LGTM.
8.3.2/5:
reference; https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf I think getting an Asan/UBsan bot might be a good idea. It would probably be red 98.9% of the time, but then we would be able to look at it and say "hey, this UB right here is bad and we should feel bad, but also, that's probably where my bug is coming from." |
Well, we do have an asan bot. It's just not even getting past compilation right now - https://ci.swift.org/job/oss-swift-incremental-ASAN-RA-macos. ubsan would be cool to have as well. |
Swift had a couple places that took a reference to a
nullptr
, but then never used it. This wasn't crashing, but now that C++ stdlib assertions are enabled, it will now assert inunique_ptr::operator*
(which checks if the underlying pointer is anullptr
).