Skip to content

Disable the definition and use of swift_async_extendedFramePointerFlags on watchOS #39935

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

DougGregor
Copy link
Member

@DougGregor DougGregor commented Oct 27, 2021

The asm definition of swift_async_extendedFramePointerFlags prevents the use of bitcode with the back-deployment libraries on watchOS, so remove the definition and use of this symbol from watchOS binaries entirely. This affects whether the async bit is set in frame pointers. Setting the async bit in the frame pointer can cause older APIs (such as backtrace APIs in the OS) to crash when they encounter such frame pointers, but we cannot dynamically set it without swift_async_extendedFramePointerFlags. So, we never set the bit when back-deploying for watchOS device, to avoid said crashes.

The trade-off here is that a back-deployed watchOS app will never have the async frame pointer bit set, so async backtraces will be unavailable even when running such an app on watchOS 8 or newer. Moving the deployment target forward to watchOS 8, or running under the simulator for watchOS 8, will restore async back traces.

One can override this behavior with the option-swift-async-frame-pointer=always, which statically sets the async bit in the frame pointer. This restores async back traces on watchOS 8, but can lead to the aforementioned crashes on older versions. This approach may be suitable for debugging but is unlikely to be a good idea when deploying.

Fixes rdar://84687579.

…gs on watchOS

The asm definition of `swift_async_extendedFramePointerFlags` prevents
the use of bitcode with the back-deployment libraries, so remove the
definition and use of this symbol from watchOS binaries entirely.
Instead, always force the async frame bit to be set. This trades off
backtraces on older OS's for debuggability of newer ones. If it causes
problems, it can be disabled via the option
`-swift-async-frame-pointer=never`.

Fixes rdar://84687579.
@DougGregor DougGregor force-pushed the watchos-noasyncframepointer-backdeploy branch from 6e0f216 to 4aca32c Compare October 27, 2021 05:26
@DougGregor
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 4aca32c

@DougGregor
Copy link
Member Author

@swift-ci please clean test Linux

Introduce a few changes to the logic for watchOS concurrency
back-deployment with respect to the async frame pointer.

* Only apply the change to watchOS device targets, not simulator targets
* Only introduce the override when no specific
  `-swift-async-frame-pointer=<value>` option is provided on the
command line
* Only override the default when deploying to watchOS < 8, and
* Use "never" for the default rather than "always".

This represents a different but safer trade-off than before. Setting
the async bit in the frame pointer can cause older APIs (such as
backtrace APIs in the OS) to crash when they encounter such frame
pointers. So, with this change we never set the bit when back-deploying
for watchOS device, to avoid said crashes.

The trade-off here is that a back-deployed watchOS app will never have
the async frame pointer bit set, so async backtraces will be
unavailable even when running on watchOS 8 or newer.
@DougGregor
Copy link
Member Author

@swift-ci please test and merge

@DougGregor
Copy link
Member Author

@swift-ci please test

@DougGregor
Copy link
Member Author

@swift-ci please test Windows

@DougGregor DougGregor merged commit 9e41e37 into swiftlang:main Oct 27, 2021
@DougGregor DougGregor deleted the watchos-noasyncframepointer-backdeploy branch October 27, 2021 23:26
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.

3 participants