Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fatal error: Index out of range from subscript(position: Index) -> Element #4024

Description

@justinisdumb

What did you do?

I have an application that is live updating a chart. Its getting temperature values once per second and graphing them. After about 15 Hours I am getting a crash. Fatal error: Index out of range.
Crash is coming from ChartDataSet.swift file.

public subscript(position: Index) -> Element {
    get {
        // This is intentionally not a safe subscript to mirror
        // the behaviour of the built in Swift Collection Types
        return entries[position]    <------------Crash is here.
    }
    set {
        calcMinMax(entry: newValue)
        entries[position] = newValue
    }
}

}

My 'position' value at this point is 3754, so I know it has a value.
My 'entries' array has 4364 values in it at this point and the 3754 location does have data in it.

What did you expect to happen?

This should not be out of range. The entries array length is much longer than 3754 and it has values in it.

What happened instead?

Fatal error: Index out of range

Charts Environment

Charts version/Branch/Commit Number:. Version 3.3.0
Xcode version:. 10.2.1
Swift version: 4.2
Platform(s) running Charts: Mac OSX Mojave
macOS version running Xcode:. 10.14.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions