Skip to content
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

Regex is unreliable on K/N #3

Open
J-Swift opened this issue Nov 2, 2022 · 1 comment
Open

Regex is unreliable on K/N #3

J-Swift opened this issue Nov 2, 2022 · 1 comment

Comments

@J-Swift
Copy link

J-Swift commented Nov 2, 2022

Describe the bug
The Kotlin/Native regex engine has known issues with stack overflowing, and as such is extremely unreliable on iOS in my testing. Here are some youtrack issues about it:

https://youtrack.jetbrains.com/issue/KT-35508/EXCBADACCESScode2-address0x16d8dbff0-crashes-on-iOS-when-using-a-sequence-from-map-etc
https://youtrack.jetbrains.com/issue/KT-39789/Segfault-in-KotlinNative-regex-interpreter
https://youtrack.jetbrains.com/issue/KT-46211/KotlinNative-Stack-overflow-crash-in-Regex-classes-with-simple-pattern-and-very-large-input
https://youtrack.jetbrains.com/issue/KT-53352/Native-iOS-Crash-when-using-regex-newSingleThreadContext

I ran into this in my own code, and was only able to workaround the crash by injecting a native regex implementation (i.e. using NSRegularExpression), but then I crashed when calling into this library since it uses Regex behind the scenes 😄

To Reproduce
Steps to reproduce the behavior:

val testing = "https://static01.nyt.com/images/2017/12/17/business/15NETVOTE2/merlin_131286365_4b8e35f3-0c1e-42e9-be51-a01c779456f7-facebookJumbo.jpg?year=2017&h=550&w=1050&s=a303fe833125a071cc3c33506af0bcb7c2ea7b8550c7a3e086a1421b2f9d7388&k=ZQJBKqZ0VN"

Uri.fromStringOrNull(testing)

Smartphone (please complete the following information):

  • iPhone 14 pro simulator running ios 16.0

Additional context
The youtrack mentions increasing stack size should help, but I was unable to get that to work in my testing. Maybe I wasn't doing it right though.

Really just opening this ticket for broader awareness. I'm not sure the best approach to fixing it other than possibly rewriting using native regex. The jetbrains team does not seem keen to fixing it on their end.

@github-actions
Copy link

github-actions bot commented Nov 2, 2022

Welcome and thanks for contributing! Make sure to leave a detailed explanation of the issue.

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

No branches or pull requests

1 participant