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

[SR-11870] LLDB fails to materialize a variable when po in closure #4433

Open
AliSoftware opened this issue Nov 28, 2019 · 4 comments
Open
Assignees
Labels
bug Something isn't working LLDB for Swift

Comments

@AliSoftware
Copy link

Previous ID SR-11870
Radar rdar://problem/57549595
Original Reporter @AliSoftware
Type Bug
Environment

Version 11.1 (11A1027)

(lldb) version
lldb-1100.0.28.19
Apple Swift version 5.1 (swiftlang-1100.0.270.13 clang-1100.0.33.7) 
Additional Detail from JIRA
Votes 0
Component/s LLDB for Swift
Labels Bug
Assignee @AliSoftware
Priority Medium

md5: 8cf5f07bd6ffac493416287ecb63ea55

Issue 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 #&#8203;2, name = 'NIO-ELT-#1', stop reason = breakpoint 1.1
  * frame #&#8203;0: 0x0000000100525d18 App`closure #&#8203;6 in closure #&#8203;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 #&#8203;1: 0x0000000100526048 App`partial apply for closure #&#8203;6 in closure #&#8203;4 in routes(router:github:ci:slack:commands:) at <compiler-generated>:0
    frame #&#8203;2: 0x0000000100507ce2 App`thunk for @escaping @callee_guaranteed (@guaranteed [ChangelogSection]) -> (@owned EventLoopFuture<(JiraService.CreatedIssue, [ChangelogSection])>, @error @owned Error) at <compiler-generated>:0
    frame #&#8203;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 #&#8203;4: 0x000000010123ea00 Async`closure #&#8203;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 #&#8203;5: 0x00000001013178e2 NIO`closure #&#8203;1 in EventLoopFuture.whenSuccess(self=0x000000010180e100, callback=0x000000010123eb70 Async`partial apply forwarder for closure #&#8203;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 #&#8203;6: 0x00000001013152a2 NIO`EventLoopFuture._addCallback(callback=0x0000000101319ea0 NIO`partial apply forwarder for closure #&#8203;1 () -> NIO.(CallbackList in _1CAEE0056AB83634CE1A29DE57BC300C) in NIO.EventLoopFuture.whenSuccess((A) -> ()) -> () at <compiler-generated>, self=0x000000010180e100) at EventLoopFuture.swift:597:16
    frame #&#8203;7: 0x0000000101315492 NIO`EventLoopFuture._whenComplete(callback=0x0000000101319ea0 NIO`partial apply forwarder for closure #&#8203;1 () -> NIO.(CallbackList in _1CAEE0056AB83634CE1A29DE57BC300C) in NIO.EventLoopFuture.whenSuccess((A) -> ()) -> () at <compiler-generated>, self=0x000000010180e100) at EventLoopFuture.swift:603:13
    frame #&#8203;8: 0x000000010131659a NIO`EventLoopFuture.whenSuccess(callback=0x000000010123eb70 Async`partial apply forwarder for closure #&#8203;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 #&#8203;9: 0x000000010123c1d8 Async`EventLoopFuture.do(callback=0x000000010123eb70 Async`partial apply forwarder for closure #&#8203;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 #&#8203;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 #&#8203;11: 0x0000000100524aa2 App`closure #&#8203;4 in routes(request=0x000000010180cc50) at routes.swift:48:14
    frame #&#8203;12: 0x0000000100523463 App`thunk for @escaping @callee_guaranteed (@guaranteed Request) -> (@owned EventLoopFuture<Response>, @error @owned Error) at <compiler-generated>:0
    frame #&#8203;13: 0x0000000100525294 App`thunk for @escaping @callee_guaranteed (@guaranteed Request) -> (@owned EventLoopFuture<Response>, @error @owned Error)partial apply at <compiler-generated>:0
    frame #&#8203;14: 0x00000001007aea62 Vapor`closure #&#8203;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 #&#8203;15: 0x00000001007aec43 Vapor`partial apply for closure #&#8203;1 in Router._on<A>(_:at:use:) at <compiler-generated>:0
    frame #&#8203;16: 0x00000001007a6476 Vapor`BasicResponder.respond(req=0x000000010180cc50, self=(closure = 0x00000001007aec00 Vapor`partial apply forwarder for closure #&#8203;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 #&#8203;17: 0x00000001007a6507 Vapor`protocol witness for Responder.respond(to:) in conformance BasicResponder at <compiler-generated>:0
    frame #&#8203;18: 0x00000001007a5f61 Vapor`RouterResponder.respond(req=0x000000010180cc50, self=Vapor.RouterResponder @ 0x000070000c27fc58) at ApplicationResponder.swift:53:30
    frame #&#8203;19: 0x00000001007a62f7 Vapor`protocol witness for Responder.respond(to:) in conformance RouterResponder at <compiler-generated>:0
    frame #&#8203;20: 0x000000010079e530 Vapor`ErrorMiddleware.respond(req=0x000000010180cc50, next=Vapor.RouterResponder @ 0x0000000101b18f30, self=(closure = 0x000000010079e3f0 Vapor`partial apply forwarder for closure #&#8203;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 #&#8203;21: 0x000000010079eca3 Vapor`protocol witness for Middleware.respond(to:chainingTo:) in conformance ErrorMiddleware at <compiler-generated>:0
    frame #&#8203;22: 0x00000001007a121e Vapor`closure #&#8203;1 in Middleware.makeResponder($0=0x000000010180cc50, self=, responder=Vapor.RouterResponder @ 0x0000000101b18f30) at Middleware.swift:32:42
    frame #&#8203;23: 0x00000001007a1323 Vapor`partial apply for closure #&#8203;1 in Middleware.makeResponder(chainingTo:) at <compiler-generated>:0
    frame #&#8203;24: 0x00000001007a6476 Vapor`BasicResponder.respond(req=0x000000010180cc50, self=(closure = 0x00000001007a1300 Vapor`partial apply forwarder for closure #&#8203;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 #&#8203;25: 0x00000001007a6507 Vapor`protocol witness for Responder.respond(to:) in conformance BasicResponder at <compiler-generated>:0
    frame #&#8203;26: 0x00000001007a5488 Vapor`ApplicationResponder.respond(req=0x000000010180cc50, self=Vapor.ApplicationResponder @ 0x0000000101b18fb0) at ApplicationResponder.swift:32:30
    frame #&#8203;27: 0x00000001007a553f Vapor`protocol witness for Responder.respond(to:) in conformance ApplicationResponder at <compiler-generated>:0
    frame #&#8203;28: 0x00000001007b40ce Vapor`NIOServerResponder.respond(http=HTTP.HTTPRequest @ 0x000070000c2807c0, worker=0x0000000101b17420, self=Vapor.NIOServerResponder @ 0x000070000c280620) at NIOServer.swift:143:34
    frame #&#8203;29: 0x00000001007b49d1 Vapor`protocol witness for HTTPServerResponder.respond(to:on:) in conformance NIOServerResponder at <compiler-generated>:0
    frame #&#8203;30: 0x0000000100c029ec HTTP`HTTPServerHandler.respond(head=NIOHTTP1.HTTPRequestHead @ 0x000070000c2809a0, body=HTTP.HTTPBody @ 0x000070000c2809e0, ctx=0x00000001048b6500, self=0x000000010180c4c0) at HTTPServer.swift:215:29
    frame #&#8203;31: 0x0000000100c01f62 HTTP`HTTPServerHandler.channelRead(ctx=0x00000001048b6500, data=NIO.NIOAny @ 0x000070000c281598, self=0x000000010180c4c0) at HTTPServer.swift:201:17
    frame #&#8203;32: 0x0000000100c06639 HTTP`protocol witness for _ChannelInboundHandler.channelRead(ctx:data:) in conformance HTTPServerHandler<A> at <compiler-generated>:0
    frame #&#8203;33: 0x00000001012dee64 NIO`ChannelHandlerContext.invokeChannelRead(data=NIO.NIOAny @ 0x000070000c281598, self=0x00000001048b6500) at ChannelPipeline.swift:1322:28
    frame #&#8203;34: 0x00000001012e2b33 NIO`ChannelHandlerContext.fireChannelRead(data=NIO.NIOAny @ 0x000070000c281598, self=0x0000000101e05270) at ChannelPipeline.swift:1135:20
    frame #&#8203;35: 0x0000000100cce5cd NIOHTTP1`HTTPDecoder.firePendingInOut(ctx=0x0000000101e05270, self=0x0000000101e044b0) at HTTPDecoder.swift:516:17
    frame #&#8203;36: 0x0000000100cce17e NIOHTTP1`HTTPDecoder.decodeHTTP(ctx=0x0000000101e05270, self=0x0000000101e044b0) at HTTPDecoder.swift:504:18
    frame #&#8203;37: 0x0000000100cd040d NIOHTTP1`HTTPDecoder.channelRead(ctx=0x0000000101e05270, data=NIO.NIOAny @ 0x000070000c2821c0, self=0x0000000101e044b0) at HTTPDecoder.swift:601:22
    frame #&#8203;38: 0x0000000100cd9c61 NIOHTTP1`protocol witness for _ChannelInboundHandler.channelRead(ctx:data:) in conformance HTTPDecoder<A> at <compiler-generated>:0
    frame #&#8203;39: 0x00000001012dee64 NIO`ChannelHandlerContext.invokeChannelRead(data=NIO.NIOAny @ 0x000070000c2821c0, self=0x0000000101e05270) at ChannelPipeline.swift:1322:28
    frame #&#8203;40: 0x00000001012deef5 NIO`ChannelHandlerContext.invokeChannelRead(data=NIO.NIOAny @ 0x000070000c2821c0, self=0x0000000101e05160) at ChannelPipeline.swift:1324:24
    frame #&#8203;41: 0x00000001012d8ead NIO`ChannelPipeline.fireChannelRead0(data=NIO.NIOAny @ 0x000070000c2821c0, self=0x0000000101e03c10) at ChannelPipeline.swift:845:29
    frame #&#8203;42: 0x00000001013885b4 NIO`SocketChannel.readFromSocket(self=0x0000000101e034b0) at SocketChannel.swift:144:30
    frame #&#8203;43: 0x000000010129307b NIO`BaseSocketChannel.readable0(self=0x0000000101e034b0) at BaseSocketChannel.swift:966:30
    frame #&#8203;44: 0x00000001012947ce NIO`BaseSocketChannel.readable(self=0x0000000101e034b0) at BaseSocketChannel.swift:950:14
    frame #&#8203;45: 0x0000000101295a09 NIO`protocol witness for SelectableChannel.readable() in conformance BaseSocketChannel<A> at <compiler-generated>:0
    frame #&#8203;46: 0x00000001013058ca NIO`SelectableEventLoop.handleEvent<C>(ev=(rawValue = 4), channel=0x0000000101e034b0, self=0x0000000101b17420) at EventLoop.swift:637:25
    frame #&#8203;47: 0x0000000101306bd9 NIO`closure #&#8203;1 in closure #&#8203;1 in SelectableEventLoop.run(ev=NIO.SelectorEvent<NIO.NIORegistration> @ 0x000070000c282b78, self=0x0000000101b17420) at EventLoop.swift:686:30
    frame #&#8203;48: 0x0000000101306c97 NIO`thunk for @callee_guaranteed (@guaranteed SelectorEvent<NIORegistration>) -> (@error @owned Error) at <compiler-generated>:0
    frame #&#8203;49: 0x000000010130fb64 NIO`partial apply for thunk for @callee_guaranteed (@guaranteed SelectorEvent<NIORegistration>) -> (@error @owned Error) at <compiler-generated>:0
    frame #&#8203;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 #&#8203;51: 0x00000001013069ba NIO`closure #&#8203;1 in SelectableEventLoop.run(self=0x0000000101b17420, nextReadyTask=nil) at EventLoop.swift:681:30
    frame #&#8203;52: 0x000000010130cc94 NIO`partial apply for closure #&#8203;1 in SelectableEventLoop.run() at <compiler-generated>:0
    frame #&#8203;53: 0x000000010128981f NIO`thunk for @callee_guaranteed () -> (@error @owned Error) at <compiler-generated>:0
    frame #&#8203;54: 0x000000010130ccb4 NIO`thunk for @callee_guaranteed () -> (@error @owned Error)partial apply at <compiler-generated>:0
    frame #&#8203;55: 0x0000000101302ae2 NIO`closure #&#8203;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 #&#8203;56: 0x000000010130faff NIO`partial apply for closure #&#8203;1 in withAutoReleasePool<A>(_:) at <compiler-generated>:0
    frame #&#8203;57: 0x00007fff735f2f4f libswiftObjectiveC.dylib`ObjectiveC.autoreleasepool<A>(invoking: () throws -> A) throws -> A + 47
    frame #&#8203;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 #&#8203;59: 0x0000000101305f66 NIO`SelectableEventLoop.run(self=0x0000000101b17420) at EventLoop.swift:680:17
    frame #&#8203;60: 0x000000010130980c NIO`closure #&#8203;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 #&#8203;61: 0x000000010130f64a NIO`partial apply for closure #&#8203;1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:initializer:) at <compiler-generated>:0
    frame #&#8203;62: 0x0000000101309dbf NIO`thunk for @escaping @callee_guaranteed (@guaranteed Thread) -> () at <compiler-generated>:0
    frame #&#8203;63: 0x00000001013a2e61 NIO`partial apply for thunk for @escaping @callee_guaranteed (@guaranteed Thread) -> () at <compiler-generated>:0
    frame #&#8203;64: 0x00000001013a321b NIO`closure #&#8203;1 in static Thread.spawnAndRun(p=(_rawValue = 0x0000000101807930)) at Thread.swift:104:13
    frame #&#8203;65: 0x00000001013a3299 NIO`@objc closure #&#8203;1 in static Thread.spawnAndRun(name:body:) at <compiler-generated>:0
    frame #&#8203;66: 0x00000001016d2dc3 libsystem_pthread.dylib`_pthread_body + 126
    frame #&#8203;67: 0x00000001016d5e8d libsystem_pthread.dylib`_pthread_start + 66
    frame #&#8203;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)

@gottesmm
Copy link
Member

@dcci Any thoughts?

@beccadax
Copy link

beccadax commented Dec 2, 2019

@swift-ci create

@adrian-prantl
Copy link
Member

I've had trouble building the project. I assume this still happens with Swift 5.2 (Latest Xcode 11.4 beta)?

@weissi
Copy link
Member

weissi commented Mar 19, 2021

friendly ping @AliSoftware

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working LLDB for Swift
Projects
None yet
Development

No branches or pull requests

5 participants