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

String.append method causes malloc error, but appending by "+=" does not

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Duplicate
    • Component/s: Compiler
    • Environment:

      macOS Sierra 10.12.4
      MacBook Pro (Retina, 13-inch, Early 2015)
      2,9 GHz Intel Core i5
      8 GB 1867 Mhz DDR3
      Intel Iris Graphics 6100 1536 MB

      Xcode 8.3.1

      Description

      Hi!

      I wrote a simple Swift program for college and ran into a problem. After compiling it for Release it started crashing on line 58 with the following error:

      MNP3(4498,0x1008b53c0) malloc: *** error for object 0x10200e600: incorrect checksum for freed object - object was probably modified after being freed.

      The strange thing is, when I replace the line 58 with:

      predictedPoints += [(distanceWeDontKnowHeightFor, searchedHeight)]

      so basically use "+=" instead of ".append" to append an element, the problem vanishes.

      I attached two files in this ticket, the first one is obviously the source code. The second contains data needed for my program to run. If you want to try it by yourself you should specify the path to the second file in the line 12 of the source code.

        Attachments

        1. data.csv
          18 kB
          Mateusz Zaporowski
        2. main.swift
          2 kB
          Mateusz Zaporowski

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              florian96 Mateusz Zaporowski
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: