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

Application of regex ([^a-zA-Z]|^)(text)(?=([^a-zA-Z]|$)) crashes #782

Open
stefanspringer1 opened this issue Oct 25, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@stefanspringer1
Copy link

Description

The code below that is supposed to replace matches of a regex crashes with Thread 1: EXC_BREAKPOINT (code=1, subcode=0x2676b2ff8) (also with e.g. just "(text)" as input).

Reproduction

print("text".replacing(/([^a-zA-Z]|^)(text)(?=([^a-zA-Z]|$))/) { match in
    "\(match.output.1) \(match.output.2) "
})

Stack dump

Thread 1 Queue : com.apple.main-thread (serial)
#0	0x00000002676b2ff8 in _StringProcessing.constructExistentialOutputComponent(from: Swift.String, component: Swift.Optional<(range: Swift.Range<Swift.String.Index>, value: Swift.Optional<Any>)>, optionalCount: Swift.Int) -> Any ()
swiftlang/swift#1	0x00000002676b3700 in generic specialization <_StringProcessing.AnyRegexOutput> of Swift.Sequence< where τ_0_0.Element == _StringProcessing.AnyRegexOutput.Element>.existentialOutput(from: Swift.String) -> Any ()
swiftlang/swift#2	0x00000002676de864 in _StringProcessing.Regex.Match.output.getter : τ_0_0 ()
swiftlang/swift#3	0x0000000103bbe7c8 in closure swiftlang/swift#1 in XMLDiffTests.testXXX() at /Users/stefan/Projekte/X-Swift/XMLDiffer/Tests/XMLDifferTests/XMLDifferTests.swift:18
swiftlang/swift#4	0x0000000267699954 in Swift.RangeReplaceableCollection< where τ_0_0.SubSequence == Swift.Substring>.replacing<τ_0_0, τ_0_1, τ_0_2 where τ_1_0 == τ_1_2.RegexOutput, τ_1_1: Swift.Collection, τ_1_2: _StringProcessing.RegexComponent, τ_1_1.Element == Swift.Character>(_: τ_1_2, subrange: Swift.Range<Swift.String.Index>, maxReplacements: Swift.Int, with: (_StringProcessing.Regex<τ_1_0>.Match) throws -> τ_1_1) throws -> τ_0_0 ()
swiftlang/swift#5	0x0000000267699d88 in Swift.RangeReplaceableCollection< where τ_0_0.SubSequence == Swift.Substring>.replacing<τ_0_0, τ_0_1, τ_0_2 where τ_1_0 == τ_1_2.RegexOutput, τ_1_1: Swift.Collection, τ_1_2: _StringProcessing.RegexComponent, τ_1_1.Element == Swift.Character>(_: τ_1_2, maxReplacements: Swift.Int, with: (_StringProcessing.Regex<τ_1_0>.Match) throws -> τ_1_1) throws -> τ_0_0 ()
swiftlang/swift#6	0x0000000103bbe678 in XMLDiffTests.testXXX() at /Users/stefan/Projekte/X-Swift/XMLDiffer/Tests/XMLDifferTests/XMLDifferTests.swift:17
swiftlang/swift#7	0x0000000103bbec3c in @objc XMLDiffTests.testXXX() ()
swiftlang/swift#8	0x000000019fdc5694 in __invoking___ ()
swiftlang/swift#9	0x000000019fdc5514 in -[NSInvocation invoke] ()
swiftlang/swift#10	0x0000000100d48fc0 in +[XCTFailableInvocation invokeErrorConventionInvocation:completion:] ()
swiftlang/swift#11	0x0000000100d48f58 in __90+[XCTFailableInvocation invokeInvocation:withTestMethodConvention:lastObservedErrorIssue:]_block_invoke ()
swiftlang/swift#12	0x0000000100d4892c in __81+[XCTFailableInvocation invokeWithAsynchronousWait:lastObservedErrorIssue:block:]_block_invoke ()
swiftlang/swift#13	0x0000000100d27348 in __49+[XCTSwiftErrorObservation observeErrorsInBlock:]_block_invoke ()
swiftlang/swift#14	0x00000001001ca61c in reabstraction thunk helper from @callee_unowned @convention(block) () -> () to @escaping @callee_guaranteed () -> () ()
swiftlang/swift#15	0x00000001001ca310 in closure swiftlang/swift#1 () -> () in static __C.XCTSwiftErrorObservation._observeErrors(in: () -> ()) -> () -> Swift.Optional<XCTest.XCTIssue> ()
swiftlang/swift#16	0x00000001001ca344 in partial apply forwarder for closure swiftlang/swift#1 () -> () in static __C.XCTSwiftErrorObservation._observeErrors(in: () -> ()) -> () -> Swift.Optional<XCTest.XCTIssue> ()
swiftlang/swift#17	0x0000000267551a4c in Swift.TaskLocal.withValue<τ_0_0>(_: τ_0_0, operation: () throws -> τ_1_0, file: Swift.String, line: Swift.UInt) throws -> τ_1_0 ()
swiftlang/swift#18	0x00000001001ca03c in static __C.XCTSwiftErrorObservation._observeErrors(in: () -> ()) -> () -> Swift.Optional<XCTest.XCTIssue> ()
swiftlang/swift#19	0x00000001001ca560 in @objc static __C.XCTSwiftErrorObservation._observeErrors(in: () -> ()) -> () -> Swift.Optional<XCTest.XCTIssue> ()
swiftlang/swift#20	0x0000000100d27228 in +[XCTSwiftErrorObservation observeErrorsInBlock:] ()
swiftlang/swift#21	0x0000000100d486bc in +[XCTFailableInvocation invokeWithAsynchronousWait:lastObservedErrorIssue:block:] ()
swiftlang/swift#22	0x0000000100d48d68 in +[XCTFailableInvocation invokeInvocation:withTestMethodConvention:lastObservedErrorIssue:] ()
swiftlang/swift#23	0x0000000100d492d8 in +[XCTFailableInvocation invokeInvocation:lastObservedErrorIssue:] ()
swiftlang/swift#24	0x0000000100cfb6cc in __24-[XCTestCase invokeTest]_block_invoke_2.106 ()
swiftlang/swift#25	0x0000000100d2bac0 in -[XCTMemoryChecker _assertInvalidObjectsDeallocatedAfterScope:] ()
swiftlang/swift#26	0x0000000100cfede4 in -[XCTestCase assertInvalidObjectsDeallocatedAfterScope:] ()
swiftlang/swift#27	0x0000000100cfb418 in __24-[XCTestCase invokeTest]_block_invoke.98 ()
swiftlang/swift#28	0x0000000100d0194c in -[XCTestCase(XCTIssueHandling) _caughtUnhandledDeveloperExceptionPermittingControlFlowInterruptions:caughtInterruptionException:whileExecutingBlock:] ()
swiftlang/swift#29	0x0000000100cfade4 in -[XCTestCase invokeTest] ()
swiftlang/swift#30	0x0000000100cfcd64 in __26-[XCTestCase performTest:]_block_invoke.157 ()
swiftlang/swift#31	0x0000000100d0194c in -[XCTestCase(XCTIssueHandling) _caughtUnhandledDeveloperExceptionPermittingControlFlowInterruptions:caughtInterruptionException:whileExecutingBlock:] ()
swiftlang/swift#32	0x0000000100cfc784 in __26-[XCTestCase performTest:]_block_invoke.142 ()
swiftlang/swift#33	0x0000000100cd9840 in +[XCTContext _runInChildOfContext:forTestCase:markAsReportingBase:block:] ()
swiftlang/swift#34	0x0000000100cd9728 in +[XCTContext runInContextForTestCase:markAsReportingBase:block:] ()
swiftlang/swift#35	0x0000000100cfc1dc in -[XCTestCase performTest:] ()
swiftlang/swift#36	0x0000000100cf7bc4 in -[XCTest runTest] ()
swiftlang/swift#37	0x0000000100d0854c in -[XCTestSuite runTestBasedOnRepetitionPolicy:testRun:] ()
swiftlang/swift#38	0x0000000100d083b8 in __27-[XCTestSuite performTest:]_block_invoke ()
swiftlang/swift#39	0x0000000100d07df0 in __59-[XCTestSuite _performProtectedSectionForTest:testSection:]_block_invoke ()
swiftlang/swift#40	0x0000000100cd9840 in +[XCTContext _runInChildOfContext:forTestCase:markAsReportingBase:block:] ()
swiftlang/swift#41	0x0000000100cd9728 in +[XCTContext runInContextForTestCase:markAsReportingBase:block:] ()
swiftlang/swift#42	0x0000000100d07d60 in -[XCTestSuite _performProtectedSectionForTest:testSection:] ()
swiftlang/swift#43	0x0000000100d08040 in -[XCTestSuite performTest:] ()
swiftlang/swift#44	0x0000000100cf7bc4 in -[XCTest runTest] ()
swiftlang/swift#45	0x0000000100d0854c in -[XCTestSuite runTestBasedOnRepetitionPolicy:testRun:] ()
swiftlang/swift#46	0x0000000100d083b8 in __27-[XCTestSuite performTest:]_block_invoke ()
swiftlang/swift#47	0x0000000100d07df0 in __59-[XCTestSuite _performProtectedSectionForTest:testSection:]_block_invoke ()
swiftlang/swift#48	0x0000000100cd9840 in +[XCTContext _runInChildOfContext:forTestCase:markAsReportingBase:block:] ()
swiftlang/swift#49	0x0000000100cd9728 in +[XCTContext runInContextForTestCase:markAsReportingBase:block:] ()
swiftlang/swift#50	0x0000000100d07d60 in -[XCTestSuite _performProtectedSectionForTest:testSection:] ()
swiftlang/swift#51	0x0000000100d08040 in -[XCTestSuite performTest:] ()
swiftlang/swift#52	0x0000000100cf7bc4 in -[XCTest runTest] ()
swiftlang/swift#53	0x0000000100d0854c in -[XCTestSuite runTestBasedOnRepetitionPolicy:testRun:] ()
swiftlang/swift#54	0x0000000100d083b8 in __27-[XCTestSuite performTest:]_block_invoke ()
swiftlang/swift#55	0x0000000100d07df0 in __59-[XCTestSuite _performProtectedSectionForTest:testSection:]_block_invoke ()
swiftlang/swift#56	0x0000000100cd9840 in +[XCTContext _runInChildOfContext:forTestCase:markAsReportingBase:block:] ()
swiftlang/swift#57	0x0000000100cd9728 in +[XCTContext runInContextForTestCase:markAsReportingBase:block:] ()
swiftlang/swift#58	0x0000000100d07d60 in -[XCTestSuite _performProtectedSectionForTest:testSection:] ()
swiftlang/swift#59	0x0000000100d08040 in -[XCTestSuite performTest:] ()
swiftlang/swift#60	0x0000000100cf7bc4 in -[XCTest runTest] ()
swiftlang/swift#61	0x0000000100d28690 in __89-[XCTTestRunSession executeTestsWithIdentifiers:skippingTestsWithIdentifiers:completion:]_block_invoke ()
swiftlang/swift#62	0x0000000100cd9840 in +[XCTContext _runInChildOfContext:forTestCase:markAsReportingBase:block:] ()
swiftlang/swift#63	0x0000000100cd9728 in +[XCTContext runInContextForTestCase:markAsReportingBase:block:] ()
swiftlang/swift#64	0x0000000100d28550 in -[XCTTestRunSession executeTestsWithIdentifiers:skippingTestsWithIdentifiers:completion:] ()
swiftlang/swift#65	0x0000000100d1a85c in __72-[XCTExecutionWorker enqueueTestIdentifiersToRun:testIdentifiersToSkip:]_block_invoke_2 ()
swiftlang/swift#66	0x0000000100d1bc50 in __XCTAsyncEnumerateWithWaiter_block_invoke ()
swiftlang/swift#67	0x0000000100d1be04 in __XCTAsyncEnumerate_block_invoke.116 ()
swiftlang/swift#68	0x0000000100d1a6c0 in XCTAsyncEnumerateWithWaiter ()
swiftlang/swift#69	0x0000000100d1a42c in __72-[XCTExecutionWorker enqueueTestIdentifiersToRun:testIdentifiersToSkip:]_block_invoke ()
swiftlang/swift#70	0x0000000100d1a9a0 in -[XCTExecutionWorker runWithError:] ()
swiftlang/swift#71	0x0000000100d187fc in __25-[XCTestDriver _runTests]_block_invoke.289 ()
swiftlang/swift#72	0x0000000100d32768 in -[XCTestObservationCenter _observeTestExecutionForTestBundle:inBlock:] ()
swiftlang/swift#73	0x0000000100d181a4 in -[XCTestDriver _runTests] ()
swiftlang/swift#74	0x0000000100d1a0ac in _XCTestMain ()
swiftlang/swift#75	0x0000000100002b30 in static xctesttool.xctest.main() -> () ()
swiftlang/swift#76	0x0000000100002c28 in static xctesttool.xctest.$main() -> () ()
swiftlang/swift#77	0x0000000100002c3c in main ()
swiftlang/swift#78	0x000000019f97b154 in start ()

Expected behavior

Replacing the match accordingly (printing " text ").

Environment

swift-driver version: 1.115 Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2)
Target: arm64-apple-macosx14.0

Additional information

No response

@stefanspringer1 stefanspringer1 added the bug Something isn't working label Oct 25, 2024
@hamishknight hamishknight transferred this issue from swiftlang/swift Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant