-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
| Previous ID | SR-3448 |
| Radar | None |
| Original Reporter | @marcelofabri |
| Type | Bug |
| Status | Resolved |
| Resolution | Done |
Environment
Swift version 3.0.2 (swift-3.0.2-RELEASE)
Target: x86_64-unknown-linux-gnu
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Foundation |
| Labels | Bug, Linux, RunTimeCrash |
| Assignee | None |
| Priority | Medium |
md5: 8df26be5a0425f2be5e8c1d240db4cce
relates to:
- SR-3449 Crash in String.replacingCharacters(in:, with:) on Linux
Issue Description:
When using String.replacingOccurrences(of:with:) with emoji on Linux, I get a crash. This does not happen on macOS with the Xcode 8.2 Swift build.
The crash only happens when there're occurrences of the searched substring.
Sample code:
import Foundation
let str = "\u{1F468}\u{200D}\u{1F469}\u{200D}\u{1F467}\u{200D}\u{1F466} marcelo "
let replaced = str.replacingOccurrences(of: "ce", with: "")
print(replaced)Stacktrace:
swift SwiftLint/file3.swift
0 swift 0x00000000035c37a8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1 swift 0x00000000035c3f07
2 libpthread.so.0 0x00007f17a0e7b3e0
3 libFoundation.so 0x00007f179ac812d9 _TTSf4s_gs_n___TFC10Foundation15NSMutableString17replaceCharactersfT2inVS_8_NSRange4withSS_T_ + 1161
4 libFoundation.so 0x00007f179ac8159b _TTSf4gs_gs_n_s_n___TFC10Foundation15NSMutableString18replaceOccurrencesfT2ofSS4withSS7optionsVCS_8NSString14CompareOptions5rangeVS_8_NSRange_Si + 619
5 libFoundation.so 0x00007f179ac81b3f _TTSf4gs_gs_n_s_n___TFC10Foundation8NSString20replacingOccurrencesfT2ofSS4withSS7optionsVS0_14CompareOptions5rangeVS_8_NSRange_SS + 527
6 libFoundation.so 0x00007f179ac73fa8 _TFC10Foundation8NSString20replacingOccurrencesfT2ofSS4withSS_SS + 408
7 libFoundation.so 0x00007f179ac869ff _TFE10FoundationSS20replacingOccurrencesfT2ofSS4withSS7optionsVCS_8NSString14CompareOptions5rangeGSqGVs5RangeVVSS13CharacterView5Index___SS + 255
8 libFoundation.so 0x00007f17a11e318f _TFE10FoundationSS20replacingOccurrencesfT2ofSS4withSS7optionsVCS_8NSString14CompareOptions5rangeGSqGVs5RangeVVSS13CharacterView5Index___SS + 106285199
9 swift 0x0000000000c59d58 llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) + 808
10 swift 0x0000000000c5d782 llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, char const* const*) + 1282
11 swift 0x00000000007f208b swift::RunImmediately(swift::CompilerInstance&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, swift::IRGenOptions&, swift::SILOptions const&) + 2555
12 swift 0x00000000007ea727
13 swift 0x00000000007e59a1 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2737
14 swift 0x00000000007ab0c3 main + 2787
15 libc.so.6 0x00007f179f7ae830 __libc_start_main + 240
16 swift 0x00000000007a8769 _start + 41
Stack dump:
0. Program arguments: /usr/bin/swift -frontend -interpret SwiftLint/file3.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -color-diagnostics -module-name file3
Illegal instruction