Skip to content

Crash: Swift/ContiguousArrayBuffer.swift:691: Fatal error: Index out of range #44

@agg23

Description

@agg23

Crash in local development on chat connect. Crash is marked as occurring in completeAny.

I assume the iterator was mutated during iteration.

  func connect(timeout: Duration?) async throws -> AsyncThrowingStream<
    IncomingMessage, Error
  > {
    let incomingMessages = try websocket.connect()

    let messageStream = AsyncThrowingStream<IncomingMessage, Error> { sink in
      Task {
        for try await messageString in incomingMessages {
          for receivedMessage in IncomingMessage.parse(ircOutput: messageString) {
            guard let message = receivedMessage.message else { continue }

            if case .ping = message {
              try await self.websocket.send(OutgoingMessage.pong.serialize())
              continue
            }

            await self.continuations.completeAny(matching: message)
            sink.yield(message)
          }
        }
      }
    }

    try await initialize(timeout: timeout)

    return messageStream
  }
Sila.debug.dylib`ContinuationQueue.completeAny(matching:):
    0x101522d60 <+0>:   orr    x29, x29, #0x1000000000000000
    0x101522d64 <+4>:   sub    sp, sp, #0x60
    0x101522d68 <+8>:   stp    x29, x30, [sp, #0x50]
    0x101522d6c <+12>:  str    x22, [sp, #0x48]
    0x101522d70 <+16>:  add    x29, sp, #0x50
    0x101522d74 <+20>:  str    x22, [sp, #0x20]
    0x101522d78 <+24>:  ldr    x0, [x22, #0x70]
    0x101522d7c <+28>:  mov    x8, x22
    0x101522d80 <+32>:  str    x8, [x22, #0x40]
    0x101522d84 <+36>:  bl     0x10159fbe4               ; symbol stub for: swift_unknownObjectRelease
    0x101522d88 <+40>:  add    x8, x22, #0x48
    0x101522d8c <+44>:  str    x8, [sp, #0x28]
    0x101522d90 <+48>:  add    x8, x22, #0x50
    0x101522d94 <+52>:  stur   x8, [x29, #-0x20]
    0x101522d98 <+56>:  add    x8, x22, #0x30
    0x101522d9c <+60>:  adrp   x0, 282
    0x101522da0 <+64>:  add    x0, x0, #0xab8            ; demangling cache variable for type metadata for Swift.IndexingIterator<Swift.Array<Twitch.TwitchContinuation>>
    0x101522da4 <+68>:  bl     0x1014798a8               ; __swift_instantiateConcreteTypeFromMangledName at <compiler-generated>
    0x101522da8 <+72>:  add    x8, x22, #0x20
    0x101522dac <+76>:  add    x20, x22, #0x10
    0x101522db0 <+80>:  bl     0x10159f020               ; symbol stub for: Swift.IndexingIterator.next() -> Swift.Optional<τ_0_0.Element>
->  0x101522db4 <+84>:  ldr    x10, [sp, #0x28]          ; Fatal error: Index out of range
    0x101522db8 <+88>:  ldur   x9, [x29, #-0x20]
    0x101522dbc <+92>:  ldr    x8, [x22, #0x20]
    0x101522dc0 <+96>:  stur   x8, [x29, #-0x18]
    0x101522dc4 <+100>: str    x8, [x22, #0x70]
    0x101522dc8 <+104>: ldr    x11, [x22, #0x28]
    0x101522dcc <+108>: stur   x11, [x29, #-0x10]
    0x101522dd0 <+112>: cbz    x8, 0x101522e6c           ; <+268> at ContinuationQueue.swift
    0x101522dd4 <+116>: b      0x101522dd8               ; <+120> at ContinuationQueue.swift

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions