DefaultStringInterpolation Could not allocate memory

Hi,

I'm experiencing a wired crash that I can't reproduce myself but I can see from crash logs that it is happening to our user.

The crash report shows it crashed when doing a String interpolation and I'm unsure what's going on here. I've got the relevant crash report below and anyone has any idea that would be really appreciated.

Code Block language
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000001a6042b24
Termination Signal: Trace/BPT trap: 5
Termination Reason: Namespace SIGNAL, Code 0x5
Terminating Process: exc handler [295]
Triggered by Thread: 0
Thread 0 name:
Thread 0 Crashed:
0 libswiftCore.dylib 0x00000001a6042b24 0x1a5ce1000 + 3545892
1 libswiftCore.dylib 0x00000001a5fd5a20 0x1a5ce1000 + 3099168
2 libswiftCore.dylib 0x00000001a5fd5b50 0x1a5ce1000 + 3099472
3 libswiftCore.dylib 0x00000001a5e8fc5c 0x1a5ce1000 + 1764444
4 libswiftCore.dylib 0x00000001a5e8494c 0x1a5ce1000 + 1718604
5 libswiftCore.dylib 0x00000001a5e84b34 0x1a5ce1000 + 1719092
6 libswiftCore.dylib 0x00000001a5e72a74 0x1a5ce1000 + 1645172
7 MyApp 0x00000001023c3be0 DefaultStringInterpolation.write(_:) + 16 (<compiler-generated>:0)
8 MyApp 0x00000001023c3be0 protocol witness for TextOutputStream.write(_:) in conformance DefaultStringInterpolation + 16 (<compiler-generated>:0)
9 MyApp 0x00000001023c3be0 specialized String.write<A>(to:) + 16 (<compiler-generated>:0)
10 MyApp 0x00000001023c3be0 specialized protocol witness for TextOutputStreamable.write<A>(to:) in conformance String + 16 (<compiler-generated>:0)
11 MyApp 0x00000001023c3be0 specialized DefaultStringInterpolation.appendInterpolation<A>(_:) + 16 (GraphClient.swift:0)
12 MyApp 0x00000001023c3be0 specialized GraphClient.init(storeDomain:additionalHeaders:authorisationSource:) + 208
13 MyApp 0x00000001023c4ea0 specialized GraphClient.init(storeDomain:additionalHeaders:authorisationSource:) + 24 (<compiler-generated>:74)
14 MyApp 0x00000001023c4ea0 GraphClient.init(storeDomain:additionalHeaders:authorisationSource:) + 24 (<compiler-generated>:0)
15 MyApp 0x00000001023c4ea0 specialized GraphClient.__allocating_init(storeDomain:additionalHeaders:authorisationSource:) + 24 (<compiler-generated>:74)
16 MyApp 0x00000001023c4ea0 GraphClient.__allocating_init(storeDomain:additionalHeaders:authorisationSource:) + 24 (MyAppHTTPClient.swift:180)
17 MyApp 0x00000001023c4ea0 MyAppHTTPClient.createGraphClient() + 24 (HTTPClient.swift:177)


Can you show your code?
How did you determine this is because memory couldn't be allocated? EXC_BREAKPOINT (SIGTRAP) is an indication of an assertion or precondition failure, with the top frames in the Swift standard library being key to understanding what's happening. Can you post the full crash report that's fully symbolicated? We need the entire crash report to know the load addresses of all the binaries in the Binary Images section at the bottom.

I've got this more symbolicated crash report hopefully it will help.

Also here is the code for the GraphClient Init method that referenced in the crash log

init(storeDomain: String, additionalHeaders: [String: String], authorisationSource: APIAuthorizationSource) {
        let baseHost: String
        #if DEVSTORE
        baseHost = "abc.com"
        #else
        baseHost = "efg.com"
        #endif
        let url = URL(string: "https://\(storeDomain).\(baseHost)/api/graphql")!
        let store = ApolloStore(cache: InMemoryNormalizedCache())
        let provider = NetworkInterceptorProvider(authorisationSource, store: store)
        let nt = RequestChainNetworkTransport(interceptorProvider: provider,
                                              endpointURL: url,
                                              additionalHeaders: additionalHeaders)
        apollo = ApolloClient(networkTransport: nt, store: store)
        apollo.cacheKeyForObject = { [$0["__typename"], $0["id"]] }
}

My guess is that the problem is at line let url = URL(string: "https://\(storeDomain).\(baseHost)/api/graphql")! with string interpolation. I don't think the force unwrap for of URL here is the cause here but open for any suggestions.

The GraphClient is created inside another class.

func createGraphClient() -> GraphClient {
    return GraphClient(storeDomain: domain,
              additionalHeaders: additionalHeaders,
              authorisationSource: self)
  }

The domain passed in here is a private(set) var domain: String This variable is set on init based on some user input or after some API callback handler. But it won't be set to nil.

DefaultStringInterpolation Could not allocate memory
 
 
Q