-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[SR-11093] EXC_BAD_ACCESS with large structs #53485
Comments
@eeckstein, aschwaighofer@apple.com (JIRA User), does this sound familiar? Note that they're using Swift 5.0. |
It could be a new issue. We had some problems with large structs in the past, but AFAIK, those were fixed in Swift 5.0. |
Comment by Brian McLachlin (JIRA) ReSwift/ReSwift.xcodeproj/project.pbxproj has the SWIFT_VERSION as 4.2. I'll see if I can get them to update to 5.0 and then verify that it's still an issue. |
Comment by Malcolm Jarvis (JIRA) bmclachlin (JIRA User) The example project you've linked here is already using Swift 5.0 for both your app target and ReSwift. I'll update your environment description appropriately. |
Comment by Brian McLachlin (JIRA) Thanks for clearing this up mjarvis (JIRA User), I guess it is in fact an issue with Swift 5.0. |
@swift-ci create |
The crash is a stack overflow. Is it possible that you rewrite your code, e.g. use classes or copy-on-write data structures (implemented with classes) instead of plain structs? |
Comment by Brian McLachlin (JIRA) I have it working by putting a guard in to unwrap the state. guard let state = state else {
return AppState(
userState: userReducer(action: action, state: nil),
profileState: profileReducer(action: action, state: nil),
...
)
}
return AppState(
userState: userReducer(action: action, state: state.userState),
profileState: profileReducer(action: action, state: state.profileState),
...
) I assume this works because the optional `state?.` was creating a bunch of temporary objects where unwrapping it does not. Why does the original code with the optionals work in Release, but not in Debug? I modified the Apple Clang and Swift Compiler Code Generation Optimization Level on Debug to match Release, but it still breaks. |
In release mode the compiler is probably able to optimize away some of the temporary values, which then reduces the required stack frame size. |
Environment
Xcode 10.2.1
iOS 12.3.1
iPhone 6 - MG3C2CL/A
Swift 5.0
mac OS 10.14.5 (18F132)
Debug
CocoaPods 1.7.3
Additional Detail from JIRA
md5: 844bfcd5ba16794536a9d3fae73ae39d
Issue Description:
Getting an EXC_BAD_ACCESS with large structs, but have only been able to replicate it with the ReSwift package. I originally posted my issue in their repo, but they advised me to post the issue here as well. ReSwift/ReSwift#237
This issue only happens on device in debug mode, works fine in the simulator.
I have created a sample repository that replicates the issue. https://github.com/brianmclachlin/exc-bad-access
Project uses CocoaPods to install ReSwift. ReSwift initializes in the AppDelegate, so all you need to do is run the app.
If you remove half of the sub-states from AppState and AppReducer then you will not get the error.
The text was updated successfully, but these errors were encountered: