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

Alarm Test causes crash when Nightscout Data is interrupted #251

Closed
marionbarker opened this issue Dec 16, 2023 · 2 comments
Closed

Alarm Test causes crash when Nightscout Data is interrupted #251

marionbarker opened this issue Dec 16, 2023 · 2 comments

Comments

@marionbarker
Copy link
Collaborator

Scenario

The test Nightscout site I'm using had no data for 10 days after being previously used with LoopFollow.
LoopFollow began to crash when I started it again and began to populate the NS site with data

  • the Loop data is uploaded from a test phone
  • the glucose data is uploaded using a shell script from my computer
  • (Note that I had quit LoopFollow in the interim, when not testing it.)

Crash

Built LoopFollow with Xcode so I could find the crash:

  • fatal error index out of range for LoopFollow/Controllers/Alarms.swift, line 246 (lines 245 and 246 shown)
            let persistentHighReadings = Int(UserDefaultsRepository.alertHighPersistent.value / 5)
            let persistentHighBG = bgData[bgData.count - 1 - persistentHighReadings].sgv

printed out some values:

  • bgData.count = 6
  • persistentHighReadings = 12

leading to the index out of range

Bandaid fix

  • modified line 245 to prevent index out of range. Let it run and there were no more crashes.
            let persistentHighReadings = min(Int(UserDefaultsRepository.alertHighPersistent.value / 5), bgData.count-1)
            let persistentHighBG = bgData[bgData.count - 1 - persistentHighReadings].sgv
@marionbarker
Copy link
Collaborator Author

I located another crash point when glucose data stream was interrupted.

  • LoopFollow/Controllers/Nightscout/BGData.swift
  • line 228-230 shown below
            let latestEntryi = entries.count - 1
            let latestBG = entries[latestEntryi].sgv
            let priorBG = entries[latestEntryi - 1].sgv

modifed line 228 to this:

            let latestEntryi = min(entries.count - 1, 1)

@marionbarker
Copy link
Collaborator Author

fixed with PR #252

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant