Files
kotlin-fork/libraries/stdlib
Abduqodiri Qurbonzoda fb31a29c39 [K/N] Fix stack overflow in regex when a quantifier is matched many times
Motivation:

Users often expect simple patterns, like `[a]+` or `[^a]+`, to work fast
and without any problems, even with long strings.
Char class from the first pattern matches only 'a' and gets wrapped into
LeafQuantifierSet, and works fine with long strings indeed.
Char class from the second pattern, however, matches any character
except 'a', including supplementary code points. So, the number of chars
it consumes is not known beforehand. There is no optimization for such
char classes, and if they are matched multiple times, the stack memory
gets exhausted.

Modification:

Introduce FixedLengthQuantifierSet node.
The node represents quantifier over constructs that consume a fixed
amount of characters for a given string and index. Such constructs don't
need backtracking to find a different match. Thus, it is possible for
the node to avoid recursion when matching multiple times.

Result:

Fixes KT-46211, KT-35508 and probably KT-39789. Reproducer for the
latter issue is no longer available, but error stacktrace resembles
those of the other issues.
2022-12-19 16:40:51 +00:00
..
2022-11-25 14:09:09 +00:00
2022-11-25 14:09:09 +00:00
2022-11-25 14:09:09 +00:00
2022-09-19 19:16:40 +00:00

The Kotlin Standard Library

This module creates the standard library for Kotlin.

Notes for contributors

We use code generation to generate utility extension functions for some collection-like types like arrays, strings, Collection<T>, Sequence<T>, Map<K, V> etc.

These sources are placed into the generated folder and their names are prefixed with an underscore, for example, generated/_Collections.kt

To run the code generator, use the following command in the root directory of the project:

./gradlew :tools:kotlin-stdlib-gen:run

Note: on Windows type gradlew without the leading ./

This then runs the script which generates a significant part of stdlib sources from the templates written in a special Kotlin-based DSL.

Usage samples

If you want to author samples for the standard library, please head to the samples readme.