Index page now throws exceptions on header parsing

Hi.

I am now getting the following exception on my 'index' page: NIO-ELT-0-#1 (4): EXC_BAD_ACCESS (code=2, address=0x16fe8ff70) It is triggered from the following code in the HTTPHeaders+Directive.swift file:

private mutating func popWhitespace() {
    if let nonWhitespace = self.current.firstIndex(where: { !$0.isLinearWhitespace }) {
        self.current = self.current[nonWhitespace...]
    } else {
        self.current = ""
    }
}

Is this somehow related to my Vapor configuration, or is this a bug in Vapor?

Thank you.

Regards,
Ruslan

What request is triggering the error? It's a Vapor bug in that Vapor shouldn't crash but I'd be interested to know what you're doing to trigger the error as that's never come up before.

Additionally what version of Vapor do you have in your Package.resolved

It turns out that I was creating an infinite loop where I was checking for a presence of a certain cookie in the request but upon failing to find it, I was triggering the same check once again. I admit that it is quite stupid, but why does it fail instead of getting stuck in the loop? Is it expected?

Also, the Vapor version is 4.89.1 but I also tried rolling back to 4.89.0 and got the same result somehow. Finally, I just updated Xcode to 15.1 before stumbling upon this problem, but I do not know if it is relevant at all.

I can't replicate this failure in a brand-new repository. I might be doing something else which results in this failure.

I will try copying larger parts of the original codebase and will check the results.

An infinite loop would definitely cause this issue and should be easy to tell because your stack trace is the same over and over until the crash. This isn't a Vapor crash - it's a stack buster because you run out of stack space and that's a plain programmer error and not a Vapor issue. So if you've fixed it I wouldn't worry too much about it

1 Like