-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Exception in -[Swift.__StringStorage substringWithRange:]: #3761
Comments
So I've noticed that on our CI running macOS 11.4 doesn't have this issue, only these logs:
When running the same command on macOS 12.0 the following happens:
followed by the stack trace in the original issue. Is this a Foundation bug (or assertion) added in macOS 12.0? |
Can you share the source file that can reproduce this crash? I've found that SwiftLint crashes for specific source files are fairly easy to reduce too if you're concerned about sharing proprietary code. |
@jpsim Is there way to print the exact file where this is crashing? Otherwise I'm not sure how I can track it down in a pretty big codebase. |
The easiest way is to run SwiftLint with Xcode: https://github.com/realm/SwiftLint/blob/master/CONTRIBUTING.md#building-and-running-locally then you’ll get a breakpoint when the exception is thrown. You’ll be able to see what file was being processed when the crash occurred. alternatively you could run SwiftLint on a subset of paths, “bisecting” as you go along. |
@jpsim I found about 25 files that crash SwiftLint in our codebase. As I said in the original message of the issue, the I can see one example where this attribute reproduces the issue: @objc(
componentModelWithIdentifier:
componentNamespace:
componentName:
topicName:
imageURL:
tappedCommand:
deleteButtonTappedCommand:
)
public static func objc_componentModel(
identifier: String,
componentNamespace: String,
componentName: String,
topicName: String,
imageURL: URL?,
tappedCommand: Command,
deleteButtonTappedCommand: Command
) -> Model {
...
} Another similar example: @objc(
provideAssetLoaderWithHTTPMaximumConnectionsPerHost:
timeoutIntervalForRequest:
timeoutIntervalForResource:
)
func provideAssetLoader(
httpMaximumConnectionsPerHost: Int,
timeoutIntervalForRequest: TimeInterval,
timeoutIntervalForResource: TimeInterval
) -> URLAssetLoader I hope this helps! |
Thanks for sharing those examples, here's a reduced repro case:
|
Potential fix here: #3776 @BalestraPatrick could you please try out that branch and let me know if you're still encountering issues? |
Thanks a lot @jpsim! That fixes it 🥳 |
New Issue Checklist
Describe the bug
SwiftLint crashes with the following exception:
Environment
swiftlint version
to be sure)? 0.45.0I can reproduce it on our codebase with this:
No
xcodebuild -version
)? Xcode 13.0echo "[string here]" | swiftlint lint --no-cache --use-stdin --enable-all-rules
to quickly test if your example is really demonstrating the issue. If your example is more
complex, you can use
swiftlint lint --path [file here] --no-cache --enable-all-rules
. No, not sure how to exactly narrow this down. Is there a debug mode that shows exactly on which string swiftlint is crashing?The text was updated successfully, but these errors were encountered: