Uploaded image for project: 'Swift'
  1. Swift
  2. SR-11870

LLDB fails to materialize a variable when po in closure

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: LLDB for Swift
    • Labels:
      None
    • Environment:

      Description

      When putting a breakpoint inside a closure and trying to po crpIssue, I get the following error from lldb

      (lldb) po crpIssue
      error: Couldn't materialize: can't get size of type
      error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression 

      Using fr variable crpIssue or v crpIssue instead of po crpIssue works though and prints the variable's content

      Context

      • debugging session in Xcode, on a Vapor project (even if it's a Vapor project, the debugging session while working on the codebase was on macOS)
      • The whole project on which this happened is OSS and can be found here
      • the type of crpIssue is a typealias declared here, aliasing to this Issue<Fields> struct declared here)
        • So it's a generic struct (public struct Issue<Fields: JiraIssueFields>: Content) containing exactly one instance variable (not sure if that matters; but I mention it to emphasis that it might not be a case of https://bugs.swift.org/browse/SR-4204 then)
        • It is declared in a dedicated framework (the Stevenson.framework module)
      • the breakpoint and current instruction on which the po crpIssue command was run was here , so it was:
        • inside a closure (especially, in Vapor's context, it's a closure run on an NIO's EventLoop if that matters)
        • from a code declared inside another module (the App module) 

      Backtrace dump in case it's useful:

      (lldb) bt
      * thread #2, name = 'NIO-ELT-#1', stop reason = breakpoint 1.1
        * frame #0: 0x0000000100525d18 App`closure #6 in closure #4 in routes(changelogSections=1 value, jira=Stevenson.JiraService @ 0x0000000101b1c620, repoMapping=App.RepoMapping @ 0x0000000101b1c848, release=Stevenson.GitHubService.Release @ 0x0000000101b1c898, container=0x000000010180cc50) at routes.swift:58:72
          frame #1: 0x0000000100526048 App`partial apply for closure #6 in closure #4 in routes(router:github:ci:slack:commands:) at <compiler-generated>:0
          frame #2: 0x0000000100507ce2 App`thunk for @escaping @callee_guaranteed (@guaranteed [ChangelogSection]) -> (@owned EventLoopFuture<(JiraService.CreatedIssue, [ChangelogSection])>, @error @owned Error) at <compiler-generated>:0
          frame #3: 0x00000001005261c4 App`partial apply for thunk for @escaping @callee_guaranteed (@guaranteed [ChangelogSection]) -> (@owned EventLoopFuture<(JiraService.CreatedIssue, [ChangelogSection])>, @error @owned Error) at <compiler-generated>:0
          frame #4: 0x000000010123ea00 Async`closure #1 in EventLoopFuture.flatMap<T>(expectation=1 value, callback=0x00000001005261b0 App`partial apply forwarder for reabstraction thunk helper from @escaping @callee_guaranteed (@guaranteed Swift.Array<App.ChangelogSection>) -> (@owned NIO.EventLoopFuture<(Stevenson.JiraService.CreatedIssue, Swift.Array<App.ChangelogSection>)>, @error @owned Swift.Error) to @escaping @callee_guaranteed (@in_guaranteed Swift.Array<App.ChangelogSection>) -> (@owned NIO.EventLoopFuture<(Stevenson.JiraService.CreatedIssue, Swift.Array<App.ChangelogSection>)>, @error @owned Swift.Error) at <compiler-generated>, promise=NIO.EventLoopPromise<(Stevenson.JiraService.CreatedIssue, Swift.Array<App.ChangelogSection>)> @ 0x000070000c27eb18) at Future+Map.swift:50:34
          frame #5: 0x00000001013178e2 NIO`closure #1 in EventLoopFuture.whenSuccess(self=0x000000010180e100, callback=0x000000010123eb70 Async`partial apply forwarder for closure #1 (A) -> () in (extension in Async):NIO.EventLoopFuture.flatMap<A>(to: A1.Type, _: (A) throws -> NIO.EventLoopFuture<A1>) -> NIO.EventLoopFuture<A1> at <compiler-generated>) at EventLoopFuture.swift:631:17
          frame #6: 0x00000001013152a2 NIO`EventLoopFuture._addCallback(callback=0x0000000101319ea0 NIO`partial apply forwarder for closure #1 () -> NIO.(CallbackList in _1CAEE0056AB83634CE1A29DE57BC300C) in NIO.EventLoopFuture.whenSuccess((A) -> ()) -> () at <compiler-generated>, self=0x000000010180e100) at EventLoopFuture.swift:597:16
          frame #7: 0x0000000101315492 NIO`EventLoopFuture._whenComplete(callback=0x0000000101319ea0 NIO`partial apply forwarder for closure #1 () -> NIO.(CallbackList in _1CAEE0056AB83634CE1A29DE57BC300C) in NIO.EventLoopFuture.whenSuccess((A) -> ()) -> () at <compiler-generated>, self=0x000000010180e100) at EventLoopFuture.swift:603:13
          frame #8: 0x000000010131659a NIO`EventLoopFuture.whenSuccess(callback=0x000000010123eb70 Async`partial apply forwarder for closure #1 (A) -> () in (extension in Async):NIO.EventLoopFuture.flatMap<A>(to: A1.Type, _: (A) throws -> NIO.EventLoopFuture<A1>) -> NIO.EventLoopFuture<A1> at <compiler-generated>, self=0x000000010180e100) at EventLoopFuture.swift:629:9
          frame #9: 0x000000010123c1d8 Async`EventLoopFuture.do(callback=0x000000010123eb70 Async`partial apply forwarder for closure #1 (A) -> () in (extension in Async):NIO.EventLoopFuture.flatMap<A>(to: A1.Type, _: (A) throws -> NIO.EventLoopFuture<A1>) -> NIO.EventLoopFuture<A1> at <compiler-generated>, self=0x000000010180e100) at Future+DoCatch.swift:14:9
          frame #10: 0x000000010123e880 Async`EventLoopFuture.flatMap<T>(type=(Stevenson.JiraService.CreatedIssue, [App.ChangelogSection]), callback=0x00000001005261b0 App`partial apply forwarder for reabstraction thunk helper from @escaping @callee_guaranteed (@guaranteed Swift.Array<App.ChangelogSection>) -> (@owned NIO.EventLoopFuture<(Stevenson.JiraService.CreatedIssue, Swift.Array<App.ChangelogSection>)>, @error @owned Swift.Error) to @escaping @callee_guaranteed (@in_guaranteed Swift.Array<App.ChangelogSection>) -> (@owned NIO.EventLoopFuture<(Stevenson.JiraService.CreatedIssue, Swift.Array<App.ChangelogSection>)>, @error @owned Swift.Error) at <compiler-generated>, self=0x000000010180e100) at Future+Map.swift:48:14
          frame #11: 0x0000000100524aa2 App`closure #4 in routes(request=0x000000010180cc50) at routes.swift:48:14
          frame #12: 0x0000000100523463 App`thunk for @escaping @callee_guaranteed (@guaranteed Request) -> (@owned EventLoopFuture<Response>, @error @owned Error) at <compiler-generated>:0
          frame #13: 0x0000000100525294 App`thunk for @escaping @callee_guaranteed (@guaranteed Request) -> (@owned EventLoopFuture<Response>, @error @owned Error)partial apply at <compiler-generated>:0
          frame #14: 0x00000001007aea62 Vapor`closure #1 in Router._on<Self>($0=0x000000010180cc50, closure=0x0000000100525280 App`reabstraction thunk helper from @escaping @callee_guaranteed (@guaranteed Vapor.Request) -> (@owned NIO.EventLoopFuture<Vapor.Response>, @error @owned Swift.Error) to @escaping @callee_guaranteed (@guaranteed Vapor.Request) -> (@out NIO.EventLoopFuture<Vapor.Response>, @error @owned Swift.Error)partial apply forwarder with unmangled suffix ".10" at <compiler-generated>) at Router+Method.swift:216:46
          frame #15: 0x00000001007aec43 Vapor`partial apply for closure #1 in Router._on<A>(_:at:use:) at <compiler-generated>:0
          frame #16: 0x00000001007a6476 Vapor`BasicResponder.respond(req=0x000000010180cc50, self=(closure = 0x00000001007aec00 Vapor`partial apply forwarder for closure #1 (Vapor.Request) throws -> NIO.EventLoopFuture<Vapor.Response> in (extension in Vapor):Vapor.Router.(_on in _DC215B321D04E127FA772E994FDF6B21)<A where A1: Vapor.ResponseEncodable>(_: NIOHTTP1.HTTPMethod, at: Swift.Array<Routing.PathComponent>, use: (Vapor.Request) throws -> A1) -> Routing.Route<Vapor.Responder> at <compiler-generated>)) at BasicResponder.swift:21:20
          frame #17: 0x00000001007a6507 Vapor`protocol witness for Responder.respond(to:) in conformance BasicResponder at <compiler-generated>:0
          frame #18: 0x00000001007a5f61 Vapor`RouterResponder.respond(req=0x000000010180cc50, self=Vapor.RouterResponder @ 0x000070000c27fc58) at ApplicationResponder.swift:53:30
          frame #19: 0x00000001007a62f7 Vapor`protocol witness for Responder.respond(to:) in conformance RouterResponder at <compiler-generated>:0
          frame #20: 0x000000010079e530 Vapor`ErrorMiddleware.respond(req=0x000000010180cc50, next=Vapor.RouterResponder @ 0x0000000101b18f30, self=(closure = 0x000000010079e3f0 Vapor`partial apply forwarder for closure #1 (Vapor.Request, Swift.Error) -> Vapor.Response in static Vapor.ErrorMiddleware.default(environment: Service.Environment, log: Logging.Logger) -> Vapor.ErrorMiddleware at <compiler-generated>)) at ErrorMiddleware.swift:90:33
          frame #21: 0x000000010079eca3 Vapor`protocol witness for Middleware.respond(to:chainingTo:) in conformance ErrorMiddleware at <compiler-generated>:0
          frame #22: 0x00000001007a121e Vapor`closure #1 in Middleware.makeResponder($0=0x000000010180cc50, self=, responder=Vapor.RouterResponder @ 0x0000000101b18f30) at Middleware.swift:32:42
          frame #23: 0x00000001007a1323 Vapor`partial apply for closure #1 in Middleware.makeResponder(chainingTo:) at <compiler-generated>:0
          frame #24: 0x00000001007a6476 Vapor`BasicResponder.respond(req=0x000000010180cc50, self=(closure = 0x00000001007a1300 Vapor`partial apply forwarder for closure #1 (Vapor.Request) throws -> NIO.EventLoopFuture<Vapor.Response> in (extension in Vapor):Vapor.Middleware.makeResponder(chainingTo: Vapor.Responder) -> Vapor.Responder at <compiler-generated>)) at BasicResponder.swift:21:20
          frame #25: 0x00000001007a6507 Vapor`protocol witness for Responder.respond(to:) in conformance BasicResponder at <compiler-generated>:0
          frame #26: 0x00000001007a5488 Vapor`ApplicationResponder.respond(req=0x000000010180cc50, self=Vapor.ApplicationResponder @ 0x0000000101b18fb0) at ApplicationResponder.swift:32:30
          frame #27: 0x00000001007a553f Vapor`protocol witness for Responder.respond(to:) in conformance ApplicationResponder at <compiler-generated>:0
          frame #28: 0x00000001007b40ce Vapor`NIOServerResponder.respond(http=HTTP.HTTPRequest @ 0x000070000c2807c0, worker=0x0000000101b17420, self=Vapor.NIOServerResponder @ 0x000070000c280620) at NIOServer.swift:143:34
          frame #29: 0x00000001007b49d1 Vapor`protocol witness for HTTPServerResponder.respond(to:on:) in conformance NIOServerResponder at <compiler-generated>:0
          frame #30: 0x0000000100c029ec HTTP`HTTPServerHandler.respond(head=NIOHTTP1.HTTPRequestHead @ 0x000070000c2809a0, body=HTTP.HTTPBody @ 0x000070000c2809e0, ctx=0x00000001048b6500, self=0x000000010180c4c0) at HTTPServer.swift:215:29
          frame #31: 0x0000000100c01f62 HTTP`HTTPServerHandler.channelRead(ctx=0x00000001048b6500, data=NIO.NIOAny @ 0x000070000c281598, self=0x000000010180c4c0) at HTTPServer.swift:201:17
          frame #32: 0x0000000100c06639 HTTP`protocol witness for _ChannelInboundHandler.channelRead(ctx:data:) in conformance HTTPServerHandler<A> at <compiler-generated>:0
          frame #33: 0x00000001012dee64 NIO`ChannelHandlerContext.invokeChannelRead(data=NIO.NIOAny @ 0x000070000c281598, self=0x00000001048b6500) at ChannelPipeline.swift:1322:28
          frame #34: 0x00000001012e2b33 NIO`ChannelHandlerContext.fireChannelRead(data=NIO.NIOAny @ 0x000070000c281598, self=0x0000000101e05270) at ChannelPipeline.swift:1135:20
          frame #35: 0x0000000100cce5cd NIOHTTP1`HTTPDecoder.firePendingInOut(ctx=0x0000000101e05270, self=0x0000000101e044b0) at HTTPDecoder.swift:516:17
          frame #36: 0x0000000100cce17e NIOHTTP1`HTTPDecoder.decodeHTTP(ctx=0x0000000101e05270, self=0x0000000101e044b0) at HTTPDecoder.swift:504:18
          frame #37: 0x0000000100cd040d NIOHTTP1`HTTPDecoder.channelRead(ctx=0x0000000101e05270, data=NIO.NIOAny @ 0x000070000c2821c0, self=0x0000000101e044b0) at HTTPDecoder.swift:601:22
          frame #38: 0x0000000100cd9c61 NIOHTTP1`protocol witness for _ChannelInboundHandler.channelRead(ctx:data:) in conformance HTTPDecoder<A> at <compiler-generated>:0
          frame #39: 0x00000001012dee64 NIO`ChannelHandlerContext.invokeChannelRead(data=NIO.NIOAny @ 0x000070000c2821c0, self=0x0000000101e05270) at ChannelPipeline.swift:1322:28
          frame #40: 0x00000001012deef5 NIO`ChannelHandlerContext.invokeChannelRead(data=NIO.NIOAny @ 0x000070000c2821c0, self=0x0000000101e05160) at ChannelPipeline.swift:1324:24
          frame #41: 0x00000001012d8ead NIO`ChannelPipeline.fireChannelRead0(data=NIO.NIOAny @ 0x000070000c2821c0, self=0x0000000101e03c10) at ChannelPipeline.swift:845:29
          frame #42: 0x00000001013885b4 NIO`SocketChannel.readFromSocket(self=0x0000000101e034b0) at SocketChannel.swift:144:30
          frame #43: 0x000000010129307b NIO`BaseSocketChannel.readable0(self=0x0000000101e034b0) at BaseSocketChannel.swift:966:30
          frame #44: 0x00000001012947ce NIO`BaseSocketChannel.readable(self=0x0000000101e034b0) at BaseSocketChannel.swift:950:14
          frame #45: 0x0000000101295a09 NIO`protocol witness for SelectableChannel.readable() in conformance BaseSocketChannel<A> at <compiler-generated>:0
          frame #46: 0x00000001013058ca NIO`SelectableEventLoop.handleEvent<C>(ev=(rawValue = 4), channel=0x0000000101e034b0, self=0x0000000101b17420) at EventLoop.swift:637:25
          frame #47: 0x0000000101306bd9 NIO`closure #1 in closure #1 in SelectableEventLoop.run(ev=NIO.SelectorEvent<NIO.NIORegistration> @ 0x000070000c282b78, self=0x0000000101b17420) at EventLoop.swift:686:30
          frame #48: 0x0000000101306c97 NIO`thunk for @callee_guaranteed (@guaranteed SelectorEvent<NIORegistration>) -> (@error @owned Error) at <compiler-generated>:0
          frame #49: 0x000000010130fb64 NIO`partial apply for thunk for @callee_guaranteed (@guaranteed SelectorEvent<NIORegistration>) -> (@error @owned Error) at <compiler-generated>:0
          frame #50: 0x00000001013713ab NIO`Selector.whenReady(strategy=block, body=0x000000010130fb50 NIO`partial apply forwarder for reabstraction thunk helper from @callee_guaranteed (@guaranteed NIO.SelectorEvent<NIO.NIORegistration>) -> (@error @owned Swift.Error) to @escaping @callee_guaranteed (@in_guaranteed NIO.SelectorEvent<NIO.NIORegistration>) -> (@error @owned Swift.Error) at <compiler-generated>, self=0x0000000101b17630) at Selector.swift:590:17
          frame #51: 0x00000001013069ba NIO`closure #1 in SelectableEventLoop.run(self=0x0000000101b17420, nextReadyTask=nil) at EventLoop.swift:681:30
          frame #52: 0x000000010130cc94 NIO`partial apply for closure #1 in SelectableEventLoop.run() at <compiler-generated>:0
          frame #53: 0x000000010128981f NIO`thunk for @callee_guaranteed () -> (@error @owned Error) at <compiler-generated>:0
          frame #54: 0x000000010130ccb4 NIO`thunk for @callee_guaranteed () -> (@error @owned Error)partial apply at <compiler-generated>:0
          frame #55: 0x0000000101302ae2 NIO`closure #1 in withAutoReleasePool<T>(execute=0x000000010130cca0 NIO`reabstraction thunk helper from @callee_guaranteed () -> (@error @owned Swift.Error) to @escaping @callee_guaranteed () -> (@out (), @error @owned Swift.Error)partial apply forwarder with unmangled suffix ".19" at <compiler-generated>) at EventLoop.swift:451:13
          frame #56: 0x000000010130faff NIO`partial apply for closure #1 in withAutoReleasePool<A>(_:) at <compiler-generated>:0
          frame #57: 0x00007fff735f2f4f libswiftObjectiveC.dylib`ObjectiveC.autoreleasepool<A>(invoking: () throws -> A) throws -> A + 47
          frame #58: 0x0000000101302a89 NIO`withAutoReleasePool<T>(execute=0x000000010130cca0 NIO`reabstraction thunk helper from @callee_guaranteed () -> (@error @owned Swift.Error) to @escaping @callee_guaranteed () -> (@out (), @error @owned Swift.Error)partial apply forwarder with unmangled suffix ".19" at <compiler-generated>) at EventLoop.swift:450:16
          frame #59: 0x0000000101305f66 NIO`SelectableEventLoop.run(self=0x0000000101b17420) at EventLoop.swift:680:17
          frame #60: 0x000000010130980c NIO`closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(t=(pthread = 0x000070000c284000), initializer=0x000000010130f570 NIO`partial apply forwarder for reabstraction thunk helper from @escaping @callee_guaranteed (@in_guaranteed NIO.Thread) -> (@out ()) to @escaping @callee_guaranteed (@guaranteed NIO.Thread) -> () at <compiler-generated>, self=NIO.MultiThreadedEventLoopGroup, lock=(mutex = 0x00000001018079a0), _loop=0x0000000101b17420, loopUpAndRunningGroup=0x00000001018079e0) at EventLoop.swift:892:23
          frame #61: 0x000000010130f64a NIO`partial apply for closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:initializer:) at <compiler-generated>:0
          frame #62: 0x0000000101309dbf NIO`thunk for @escaping @callee_guaranteed (@guaranteed Thread) -> () at <compiler-generated>:0
          frame #63: 0x00000001013a2e61 NIO`partial apply for thunk for @escaping @callee_guaranteed (@guaranteed Thread) -> () at <compiler-generated>:0
          frame #64: 0x00000001013a321b NIO`closure #1 in static Thread.spawnAndRun(p=(_rawValue = 0x0000000101807930)) at Thread.swift:104:13
          frame #65: 0x00000001013a3299 NIO`@objc closure #1 in static Thread.spawnAndRun(name:body:) at <compiler-generated>:0
          frame #66: 0x00000001016d2dc3 libsystem_pthread.dylib`_pthread_body + 126
          frame #67: 0x00000001016d5e8d libsystem_pthread.dylib`_pthread_start + 66
          frame #68: 0x00000001016d1e11 libsystem_pthread.dylib`thread_start + 13 

      (Note: this backtrace was actually from setting a breakpoint in some temporary code copy/pasted from Sources/App/CRP/SlackCommand+CRP.swift (where I said the breakpoint was in the bug description above) into routes.swift – in order to debug something else on that code more easily. But the lldb materialization error also happens when the breakpoint is in the original code like described in the bug description)

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            AliSoftware Olivier Halligon
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated: