Uploaded image for project: 'Swift'
  1. Swift
  2. SR-5971

[CharacterSet] `init(charactersIn string: String)` crashes when `string` contains non-BMP scalars on Linux.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Done
    • Component/s: Foundation
    • Labels:
      None
    • Environment:
      • OS: Ubuntu 16.04
      • Swift 4.0 / 3.1.1

      Description

      Very simple code below will crash on Linux.

      [Code]

      import Foundation
      let cset = CharacterSet(charactersIn:"\u{10000}" ..< "\u{10001}") // no problem 
      let cset2 = CharacterSet(charactersIn:"\u{10000}") // crashes
      

      [Result]

      * thread #1, name = 'repl_swift', stop reason = signal SIGSEGV: invalid address (fault address: 0xdc00)
          frame #0: 0x00007ffff3a85180 libFoundation.so`chcompar
      libFoundation.so`chcompar:
      ->  0x7ffff3a85180 <+0>: movzwl (%rsi), %ecx
          0x7ffff3a85183 <+3>: movzwl (%rdi), %eax
          0x7ffff3a85186 <+6>: subl   %ecx, %eax
          0x7ffff3a85188 <+8>: retq   
      Target 0: (repl_swift) stopped.
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            YOCKOW Knock YOCKOW
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: