I have recently installed Swift on my new computer. I can't get lldb running properly. Every time I try to execute some expression, following error appears:
(lldb) e -l swift -- print("Hello")
error: Couldn't materialize: couldn't write the address of variable rtcCounter to memory: memory write failed for 0x0
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
I suspect the issue is related to following warnings, that appear whenever I start a repl session:
warning: (x86_64) /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 Unable to initialize decompressor for section '.debug_abbrev': zlib is not available
warning: (x86_64) /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 Unable to initialize decompressor for section '.debug_info': zlib is not available
warning: (x86_64) /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 Unable to initialize decompressor for section '.debug_aranges': zlib is not available
warning: (x86_64) /lib64/ld-linux-x86-64.so.2 Unable to initialize decompressor for section '.debug_abbrev': zlib is not available
warning: (x86_64) /lib64/ld-linux-x86-64.so.2 Unable to initialize decompressor for section '.debug_info': zlib is not available
warning: (x86_64) /lib/x86_64-linux-gnu/libdl.so.2 Unable to initialize decompressor for section '.debug_abbrev': zlib is not available
warning: (x86_64) /lib/x86_64-linux-gnu/libdl.so.2 Unable to initialize decompressor for section '.debug_info': zlib is not available
warning: (x86_64) /lib/x86_64-linux-gnu/libc.so.6 Unable to initialize decompressor for section '.debug_abbrev': zlib is not available
warning: (x86_64) /lib/x86_64-linux-gnu/libc.so.6 Unable to initialize decompressor for section '.debug_info': zlib is not available
warning: (x86_64) /lib/x86_64-linux-gnu/libm.so.6 Unable to initialize decompressor for section '.debug_abbrev': zlib is not available
warning: (x86_64) /lib/x86_64-linux-gnu/libm.so.6 Unable to initialize decompressor for section '.debug_info': zlib is not available
warning: (x86_64) /lib/x86_64-linux-gnu/libc.so.6 Unable to initialize decompressor for section '.debug_aranges': zlib is not available
Welcome to Swift version 5.6.1 (swift-5.6.1-RELEASE).
Type :help for assistance.
I have these warnings as well on the released Ubuntu 20.04 Swift version 5.6.2
$ swift
Swift version 5.6.2 (swift-5.6.2-RELEASE)
Target: x86_64-unknown-linux-gnu
Welcome to Swift!
Subcommands:
swift build Build Swift packages
swift package Create and work on packages
swift run Run a program from a package
swift test Run package tests
swift repl Experiment with Swift code interactively (default)
Use swift --help for descriptions of available options and flags.
Use swift help <subcommand> for more information about a subcommand.
warning: (x86_64) /lib/x86_64-linux-gnu/ld-2.31.so Unable to initialize decompressor for section '.debug_abbrev': zlib is not available
warning: (x86_64) /lib/x86_64-linux-gnu/ld-2.31.so Unable to initialize decompressor for section '.debug_info': zlib is not available
warning: (x86_64) /lib/x86_64-linux-gnu/ld-2.31.so Unable to initialize decompressor for section '.debug_aranges': zlib is not available
warning: (x86_64) /lib64/ld-linux-x86-64.so.2 Unable to initialize decompressor for section '.debug_abbrev': zlib is not available
warning: (x86_64) /lib64/ld-linux-x86-64.so.2 Unable to initialize decompressor for section '.debug_info': zlib is not available
warning: (x86_64) /lib/x86_64-linux-gnu/libdl.so.2 Unable to initialize decompressor for section '.debug_abbrev': zlib is not available
warning: (x86_64) /lib/x86_64-linux-gnu/libdl.so.2 Unable to initialize decompressor for section '.debug_info': zlib is not available
warning: (x86_64) /lib/x86_64-linux-gnu/libc.so.6 Unable to initialize decompressor for section '.debug_abbrev': zlib is not available
warning: (x86_64) /lib/x86_64-linux-gnu/libc.so.6 Unable to initialize decompressor for section '.debug_info': zlib is not available
warning: (x86_64) /lib/x86_64-linux-gnu/libc.so.6 Unable to initialize decompressor for section '.debug_aranges': zlib is not available
warning: (x86_64) /lib/x86_64-linux-gnu/libm.so.6 Unable to initialize decompressor for section '.debug_abbrev': zlib is not available
warning: (x86_64) /lib/x86_64-linux-gnu/libm.so.6 Unable to initialize decompressor for section '.debug_info': zlib is not available
Welcome to Swift version 5.6.2 (swift-5.6.2-RELEASE).
Type :help for assistance.
1>
I don't think these warnings are related to your problem. The warning is about LLDB not being able to parse zlib-compressed debug info for the system libraries, because LLDB wasn't built with zlib support, but that has no effect on the JIT.
Can you re-run your expression after running (lldb) log enable lldb expr ?