swiftlang / swiftlang/swift-experimental-string-processing

Engine limiters and checking task cancellation

Open
#262 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
308
Forks
52
Avg merge
12h 45m
Merged PRs (30d)
2

Description

During proposal reviews, concerns of RDoS and responsivity came up. We should add engine limiters which can halt execution if some threshold is exceeded, either counted in time or number of byte code instructions (possibly proportional to input length). Additionally, we should check Task.checkCancellation() in case the parent task has been cancelled.

  • Basic limiter infrastructure based on engine cycle count
  • Occasionally (say every thousand bytecode instructions executed) check cancellation
  • Testing infrastructure around limiters
  • Limiters based on input length
  • Surface as API

From https://forums.swift.org/t/se-0350-regex-type-and-overview/56530/19:

In the meantime, before that is available, would it be possible to include some calls to Task.checkCancellation() during the evaluation of the match? The use case I'm thinking of for this for evaluating a user-specified Regex in an interactive application. If the match operation is taking too long, it should be possible for the user to cancel this.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue does not name specific files or tests. Start by locating the engine's bytecode execution loop and existing task-evaluation entry points, then trace how cancellation could be checked during execution. Done should include cycle-count and input-length limiter infrastructure, periodic Task.checkCancellation() checks, tests, and an exposed API.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
performance, security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.