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-14602] lldb (5.4): const: Assertion `false && "Unhandled node kind"' failed #4313

Closed
weissi opened this issue May 6, 2021 · 10 comments
Closed
Assignees
Labels
bug Something isn't working Crash LLDB for Swift

Comments

@weissi
Copy link
Member

weissi commented May 6, 2021

Previous ID SR-14602
Radar rdar://problem/77673454
Original Reporter @weissi
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

5.4-RELEASE without asserts

Additional Detail from JIRA
Votes 0
Component/s LLDB for Swift
Labels Bug, Crash
Assignee @augusto2112
Priority Medium

md5: ef3a0da316417da78977a165ff5cbeae

Issue Description:

Repro:

git clone https://github.com/apple/swift-nio
cd swift-nio && git reset c51907f551c6b2e4366b5ccbe8c0509b0b061026
swift build --build-tests
lldb --batch -o 'break set -f ByteBuffer-core.swift -l 85' -o run -o 'frame variable' -- .build/debug/swift-nioPackageTests.xctest

Result:

root@1c23930c77ef:/tmp/swift-nio# lldb --batch -o 'break set -f ByteBuffer-core.swift -l 85' -o run -o 'frame variable' -- /tmp/swift-nio/.build/debug/swift-nioPackageTests.xctest
(lldb) target create "/tmp/swift-nio/.build/debug/swift-nioPackageTests.xctest"
Current executable set to '/tmp/swift-nio/.build/debug/swift-nioPackageTests.xctest' (x86_64).
(lldb) break set -f ByteBuffer-core.swift -l 85
Breakpoint 1: where = swift-nioPackageTests.xctest`NIO.ByteBufferAllocator.init(hookedMalloc: @convention(c) (Swift.Int) -> Swift.Optional<Swift.UnsafeMutableRawPointer>, hookedRealloc: @convention(c) (Swift.Optional<Swift.UnsafeMutableRawPointer>, Swift.Int) -> Swift.Optional<Swift.UnsafeMutableRawPointer>, hookedFree: @convention(c) (Swift.Optional<Swift.UnsafeMutableRawPointer>) -> (), hookedMemcpy: @convention(c) (Swift.UnsafeMutableRawPointer, Swift.UnsafeRawPointer, Swift.Int) -> ()) -> NIO.ByteBufferAllocator + 71 at ByteBuffer-core.swift:85:19, address = 0x0000000000129377
(lldb) run
Process 17302 stopped
* thread #&#8203;1, name = 'swift-nioPackag', stop reason = breakpoint 1.1
    frame #&#8203;0: 0x000055555567d377 swift-nioPackageTests.xctest`ByteBufferAllocator.init(hookedMalloc=0x000055555567d230 swift-nioPackageTests.xctest`@objc closure #&#8203;1 (Swift.Int) -> Swift.Optional<Swift.UnsafeMutableRawPointer> in NIO.ByteBufferAllocator.init() -> NIO.ByteBufferAllocator at <compiler-generated>, hookedRealloc=0x000055555567d280 swift-nioPackageTests.xctest`@objc closure #&#8203;2 (Swift.Optional<Swift.UnsafeMutableRawPointer>, Swift.Int) -> Swift.Optional<Swift.UnsafeMutableRawPointer> in NIO.ByteBufferAllocator.init() -> NIO.ByteBufferAllocator at <compiler-generated>, hookedFree=0x000055555567d2c0 swift-nioPackageTests.xctest`@objc closure #&#8203;3 (Swift.Optional<Swift.UnsafeMutableRawPointer>) -> () in NIO.ByteBufferAllocator.init() -> NIO.ByteBufferAllocator at <compiler-generated>, hookedMemcpy=0x000055555567d320 swift-nioPackageTests.xctest`@objc closure #&#8203;4 (Swift.UnsafeMutableRawPointer, Swift.UnsafeRawPointer, Swift.Int) -> () in NIO.ByteBufferAllocator.init() -> NIO.ByteBufferAllocator at <compiler-generated>) at ByteBuffer-core.swift:85:19
   82                     hookedMemcpy: @escaping @convention(c) (UnsafeMutableRawPointer, UnsafeRawPointer, size_t) -> Void) {
   83           self.malloc = hookedMalloc
   84           self.realloc = hookedRealloc
-> 85           self.free = hookedFree
   86           self.memcpy = hookedMemcpy
   87       }
   88   
Target 0: (swift-nioPackageTests.xctest) stopped.

Process 17302 launched: '/tmp/swift-nio/.build/debug/swift-nioPackageTests.xctest' (x86_64)
(lldb) frame variable
lldb: /home/build-user/llvm-project/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp:2988: auto lldb_private::TypeSystemSwiftTypeRef::DumpTypeValue(lldb::opaque_compiler_type_t, lldb_private::Stream *, lldb::Format, const lldb_private::DataExtractor &, lldb::offset_t, size_t, uint32_t, uint32_t, lldb_private::ExecutionContextScope *, bool)::(anonymous class)::operator()() const: Assertion `false && "Unhandled node kind"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.  Program arguments: lldb --batch -o break set -f ByteBuffer-core.swift -l 85 -o run -o frame variable -- /tmp/swift-nio/.build/debug/swift-nioPackageTests.xctest 
lldb[0x421024]
lldb[0x41f0ce]
lldb[0x4214b5]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x153c0)[0x7f2d2cb853c0]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcb)[0x7f2d22fc618b]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x12b)[0x7f2d22fa5859]
/lib/x86_64-linux-gnu/libc.so.6(+0x25729)[0x7f2d22fa5729]
/lib/x86_64-linux-gnu/libc.so.6(+0x36f36)[0x7f2d22fb6f36]
/tmp/swift-5.4-RELEASE-ubuntu20.04/usr/bin/../lib/liblldb.so.10(+0x141c318)[0x7f2d2491c318]
/tmp/swift-5.4-RELEASE-ubuntu20.04/usr/bin/../lib/liblldb.so.10(+0xf8f26a)[0x7f2d2448f26a]
/tmp/swift-5.4-RELEASE-ubuntu20.04/usr/bin/../lib/liblldb.so.10(+0xf0c22d)[0x7f2d2440c22d]
/tmp/swift-5.4-RELEASE-ubuntu20.04/usr/bin/../lib/liblldb.so.10(+0xed9ec1)[0x7f2d243d9ec1]
/tmp/swift-5.4-RELEASE-ubuntu20.04/usr/bin/../lib/liblldb.so.10(+0x12399c3)[0x7f2d247399c3]
/tmp/swift-5.4-RELEASE-ubuntu20.04/usr/bin/../lib/liblldb.so.10(+0xefddcc)[0x7f2d243fddcc]
/tmp/swift-5.4-RELEASE-ubuntu20.04/usr/bin/../lib/liblldb.so.10(+0xefbd09)[0x7f2d243fbd09]
/tmp/swift-5.4-RELEASE-ubuntu20.04/usr/bin/../lib/liblldb.so.10(+0xef8fd9)[0x7f2d243f8fd9]
/tmp/swift-5.4-RELEASE-ubuntu20.04/usr/bin/../lib/liblldb.so.10(+0xef8cb9)[0x7f2d243f8cb9]
/tmp/swift-5.4-RELEASE-ubuntu20.04/usr/bin/../lib/liblldb.so.10(+0xef311f)[0x7f2d243f311f]
/tmp/swift-5.4-RELEASE-ubuntu20.04/usr/bin/../lib/liblldb.so.10(+0xed61a8)[0x7f2d243d61a8]
/tmp/swift-5.4-RELEASE-ubuntu20.04/usr/bin/../lib/liblldb.so.10(+0xef7aab)[0x7f2d243f7aab]
/tmp/swift-5.4-RELEASE-ubuntu20.04/usr/bin/../lib/liblldb.so.10(+0xf10d7e)[0x7f2d24410d7e]
/tmp/swift-5.4-RELEASE-ubuntu20.04/usr/bin/../lib/liblldb.so.10(+0xf10261)[0x7f2d24410261]
/tmp/swift-5.4-RELEASE-ubuntu20.04/usr/bin/../lib/liblldb.so.10(+0xedfb03)[0x7f2d243dfb03]
/tmp/swift-5.4-RELEASE-ubuntu20.04/usr/bin/../lib/liblldb.so.10(+0x156c15f)[0x7f2d24a6c15f]
/tmp/swift-5.4-RELEASE-ubuntu20.04/usr/bin/../lib/liblldb.so.10(+0xf61477)[0x7f2d24461477]
/tmp/swift-5.4-RELEASE-ubuntu20.04/usr/bin/../lib/liblldb.so.10(+0xf574ac)[0x7f2d244574ac]
/tmp/swift-5.4-RELEASE-ubuntu20.04/usr/bin/../lib/liblldb.so.10(+0xf5adec)[0x7f2d2445adec]
/tmp/swift-5.4-RELEASE-ubuntu20.04/usr/bin/../lib/liblldb.so.10(+0xea2456)[0x7f2d243a2456]
/tmp/swift-5.4-RELEASE-ubuntu20.04/usr/bin/../lib/liblldb.so.10(+0xe86834)[0x7f2d24386834]
/tmp/swift-5.4-RELEASE-ubuntu20.04/usr/bin/../lib/liblldb.so.10(+0xf5c52d)[0x7f2d2445c52d]
/tmp/swift-5.4-RELEASE-ubuntu20.04/usr/bin/../lib/liblldb.so.10(_ZN4lldb10SBDebugger21RunCommandInterpreterERKNS_30SBCommandInterpreterRunOptionsE+0xcd)[0x7f2d2404a85d]
lldb[0x40a70a]
lldb[0x40c7af]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0x7f2d22fa70b3]
lldb[0x40716e]
********************
Crash reproducer for lldb version 10.0.0
Swift version 5.4 (swift-5.4-RELEASE)

Reproducer written to '/tmp/reproducer-daa782'

Before attaching the reproducer to a bug report:
 - Look at the directory to ensure you're willing to share its content.
 - Make sure the reproducer works by replaying the reproducer.

Replay the reproducer with the following command:
lldb -replay /tmp/reproducer-daa782
********************
Aborted

Re-ran this

lldb --batch -o 'log enable lldb types -f /tmp/types.log' -o 'break set -f ByteBuffer-core.swift -l 85' -o run -o 'frame variable' -- .build/debug/swift-nioPackageTests.xctest

the produced /tmp/types.log is attached.

@weissi
Copy link
Member Author

weissi commented May 6, 2021

@swift-ci create

@weissi
Copy link
Member Author

weissi commented May 6, 2021

CC @adrian-prantl this is the no asserts build. Is this assert still expected?

@adrian-prantl
Copy link
Member

@swift-ci create

@weissi
Copy link
Member Author

weissi commented May 6, 2021

edited the binary to not have the assertions which now makes it work

root@c339bfad00cb:/tmp/swift-nio# lldb --batch -o 'log enable lldb types -f /tmp/types.log' -o 'break set -f ByteBuffer-core.swift -l 85' -o run -o 'frame variable' -o cont -- .build/debug/swift-nioPackageTests.xctest
(lldb) target create ".build/debug/swift-nioPackageTests.xctest"
Current executable set to '/tmp/swift-nio/.build/debug/swift-nioPackageTests.xctest' (x86_64).
(lldb) log enable lldb types -f /tmp/types.log
(lldb) break set -f ByteBuffer-core.swift -l 85
Breakpoint 1: where = swift-nioPackageTests.xctest`NIO.ByteBufferAllocator.init(hookedMalloc: @convention(c) (Swift.Int) -> Swift.Optional<Swift.UnsafeMutableRawPointer>, hookedRealloc: @convention(c) (Swift.Optional<Swift.UnsafeMutableRawPointer>, Swift.Int) -> Swift.Optional<Swift.UnsafeMutableRawPointer>, hookedFree: @convention(c) (Swift.Optional<Swift.UnsafeMutableRawPointer>) -> (), hookedMemcpy: @convention(c) (Swift.UnsafeMutableRawPointer, Swift.UnsafeRawPointer, Swift.Int) -> ()) -> NIO.ByteBufferAllocator + 71 at ByteBuffer-core.swift:85:19, address = 0x0000000000129537
(lldb) run
Process 1513 stopped
* thread #&#8203;1, name = 'swift-nioPackag', stop reason = breakpoint 1.1
    frame #&#8203;0: 0x000055555567d537 swift-nioPackageTests.xctest`ByteBufferAllocator.init(hookedMalloc=0x000055555567d3f0 swift-nioPackageTests.xctest`@objc closure #&#8203;1 (Swift.Int) -> Swift.Optional<Swift.UnsafeMutableRawPointer> in NIO.ByteBufferAllocator.init() -> NIO.ByteBufferAllocator at <compiler-generated>, hookedRealloc=0x000055555567d440 swift-nioPackageTests.xctest`@objc closure #&#8203;2 (Swift.Optional<Swift.UnsafeMutableRawPointer>, Swift.Int) -> Swift.Optional<Swift.UnsafeMutableRawPointer> in NIO.ByteBufferAllocator.init() -> NIO.ByteBufferAllocator at <compiler-generated>, hookedFree=0x000055555567d480 swift-nioPackageTests.xctest`@objc closure #&#8203;3 (Swift.Optional<Swift.UnsafeMutableRawPointer>) -> () in NIO.ByteBufferAllocator.init() -> NIO.ByteBufferAllocator at <compiler-generated>, hookedMemcpy=0x000055555567d4e0 swift-nioPackageTests.xctest`@objc closure #&#8203;4 (Swift.UnsafeMutableRawPointer, Swift.UnsafeRawPointer, Swift.Int) -> () in NIO.ByteBufferAllocator.init() -> NIO.ByteBufferAllocator at <compiler-generated>) at ByteBuffer-core.swift:85:19
   82                     hookedMemcpy: @escaping @convention(c) (UnsafeMutableRawPointer, UnsafeRawPointer, size_t) -> Void) {
   83           self.malloc = hookedMalloc
   84           self.realloc = hookedRealloc
-> 85           self.free = hookedFree
   86           self.memcpy = hookedMemcpy
   87       }
   88   
Target 0: (swift-nioPackageTests.xctest) stopped.

Process 1513 launched: '/tmp/swift-nio/.build/debug/swift-nioPackageTests.xctest' (x86_64)
(lldb) frame variable
() hookedMalloc = 0x000055555567d3f0 swift-nioPackageTests.xctest`@objc closure #&#8203;1 (Swift.Int) -> Swift.Optional<Swift.UnsafeMutableRawPointer> in NIO.ByteBufferAllocator.init() -> NIO.ByteBufferAllocator at <compiler-generated>
() hookedRealloc = 0x000055555567d440 swift-nioPackageTests.xctest`@objc closure #&#8203;2 (Swift.Optional<Swift.UnsafeMutableRawPointer>, Swift.Int) -> Swift.Optional<Swift.UnsafeMutableRawPointer> in NIO.ByteBufferAllocator.init() -> NIO.ByteBufferAllocator at <compiler-generated>
() hookedFree = 0x000055555567d480 swift-nioPackageTests.xctest`@objc closure #&#8203;3 (Swift.Optional<Swift.UnsafeMutableRawPointer>) -> () in NIO.ByteBufferAllocator.init() -> NIO.ByteBufferAllocator at <compiler-generated>
() hookedMemcpy = 0x000055555567d4e0 swift-nioPackageTests.xctest`@objc closure #&#8203;4 (Swift.UnsafeMutableRawPointer, Swift.UnsafeRawPointer, Swift.Int) -> () in NIO.ByteBufferAllocator.init() -> NIO.ByteBufferAllocator at <compiler-generated>
(NIO.ByteBufferAllocator) self = {
  malloc = 0x000055555567d3f0 swift-nioPackageTests.xctest`@objc closure #&#8203;1 (Swift.Int) -> Swift.Optional<Swift.UnsafeMutableRawPointer> in NIO.ByteBufferAllocator.init() -> NIO.ByteBufferAllocator at <compiler-generated>
  realloc = 0x000055555567d440 swift-nioPackageTests.xctest`@objc closure #&#8203;2 (Swift.Optional<Swift.UnsafeMutableRawPointer>, Swift.Int) -> Swift.Optional<Swift.UnsafeMutableRawPointer> in NIO.ByteBufferAllocator.init() -> NIO.ByteBufferAllocator at <compiler-generated>
  free = 0x0000000000000000
  memcpy = {}
}
(lldb) cont
Process 1513 resuming
Process 1513 stopped
* thread #&#8203;1, name = 'swift-nioPackag', stop reason = breakpoint 1.1
    frame #&#8203;0: 0x000055555567d537 swift-nioPackageTests.xctest`ByteBufferAllocator.init(hookedMalloc=0x000055555567d3f0 swift-nioPackageTests.xctest`@objc closure #&#8203;1 (Swift.Int) -> Swift.Optional<Swift.UnsafeMutableRawPointer> in NIO.ByteBufferAllocator.init() -> NIO.ByteBufferAllocator at <compiler-generated>, hookedRealloc=0x000055555567d440 swift-nioPackageTests.xctest`@objc closure #&#8203;2 (Swift.Optional<Swift.UnsafeMutableRawPointer>, Swift.Int) -> Swift.Optional<Swift.UnsafeMutableRawPointer> in NIO.ByteBufferAllocator.init() -> NIO.ByteBufferAllocator at <compiler-generated>, hookedFree=0x000055555567d480 swift-nioPackageTests.xctest`@objc closure #&#8203;3 (Swift.Optional<Swift.UnsafeMutableRawPointer>) -> () in NIO.ByteBufferAllocator.init() -> NIO.ByteBufferAllocator at <compiler-generated>, hookedMemcpy=0x000055555567d4e0 swift-nioPackageTests.xctest`@objc closure #&#8203;4 (Swift.UnsafeMutableRawPointer, Swift.UnsafeRawPointer, Swift.Int) -> () in NIO.ByteBufferAllocator.init() -> NIO.ByteBufferAllocator at <compiler-generated>) at ByteBuffer-core.swift:85:19
   82                     hookedMemcpy: @escaping @convention(c) (UnsafeMutableRawPointer, UnsafeRawPointer, size_t) -> Void) {
   83           self.malloc = hookedMalloc
   84           self.realloc = hookedRealloc
-> 85           self.free = hookedFree
   86           self.memcpy = hookedMemcpy
   87       }
   88   
Target 0: (swift-nioPackageTests.xctest) stopped.

root@c339bfad00cb:/tmp/swift-nio# 

the types-after-hack.log is the types log after that binary edit.

@adrian-prantl
Copy link
Member

@swift-ci Create

@weissi
Copy link
Member Author

weissi commented May 7, 2021

@adrian-prantl don't know if that helps the debugging, but those two are wrong:

  free = 0x0000000000000000
  memcpy = {}

They're always set.

@weissi
Copy link
Member Author

weissi commented May 7, 2021

@swift-ci create

@adrian-prantl
Copy link
Member

najacque (JIRA User) The sync system seems to not work.

@adrian-prantl
Copy link
Member

I manually cloned this to rdar://77668160.

@augusto2112
Copy link

Solved in PR: #3017

@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
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Crash LLDB for Swift
Projects
None yet
Development

No branches or pull requests

3 participants