-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
stage 1 produces debug info that crashes LLDB #12929
Comments
Reproduces on Darwin (macOS 12.6) and Linux (Debian Bookworm). Haven't tested other platforms. |
Compiling the program with self-hosted instead also leads to poor LLDB behavior: $ zig build-exe testme.zig
$ lldb ./testme
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'lldb.embedded_interpreter'
(lldb) target create "./testme"
Current executable set to '/home/topolarity/repos/zig/testme' (x86_64).
(lldb) br set -f testme.zig -l 5
Breakpoint 1: where = testme`testme.printTargetArch + 8 at testme.zig:5:16, address = 0x00000000002128f8
(lldb) r
Process 333395 launched: '/home/topolarity/repos/zig/testme' (x86_64)
Process 333395 stopped
* thread #1, name = 'testme', stop reason = breakpoint 1.1
frame #0: 0x00000000002128f8 testme`testme.printTargetArch at testme.zig:5:16
2 const Target = std.Target;
3
4 pub fn printTargetArch(t: Target) void {
-> 5 std.log.err("target: {}", .{ t.cpu.arch });
6 }
7
8 pub fn main() anyerror!void {
(lldb) p t
warning: (x86_64) /home/topolarity/repos/zig/testme 0x000002e9: DW_TAG_member bitfield named "payload" has invalid bit offset (0x100000000) member will be ignored. Please file a bug against the compiler and include the preprocessed output for testme
(target.Target) $0 = {
cpu = {
model = 0x0000000000201970
features = {
ints = ([0] = 17602322383593537648, [1] = 18158514333030456, [2] = 1114271, [3] = 0, [4] = 0)
}
}
os = {
version_range = {}
}
} Notice the missing "payload" field and the corresponding warning. |
Does not reproduce with Zig 0.9.1. As mentioned above, this is likely an upstream bug so I'll see if I can reduce this to some LLVM IR and file upstream. |
Reduced LLVM IR: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
define void @_start() {
Entry:
unreachable
}
define internal fastcc void @printTargetArch(ptr %0) !dbg !2251 {
Entry:
%1 = load i6, ptr null, align 1, !dbg !2258
store i6 %1, ptr %0, align 1
ret void
}
!llvm.module.flags = !{!0, !1}
!llvm.dbg.cu = !{!2}
!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !{i32 2, !"Dwarf Version", i32 4}
!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "zig 0.10.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !1306)
!3 = !DIFile(filename: "testme", directory: ".")
!4 = !{!96}
!21 = !DIBasicType(name: "u2", size: 2, encoding: DW_ATE_unsigned)
!27 = !DIFile(filename: "target.zig", directory: "/home/topolarity/repos/zig/build/stage3/lib/zig/std")
!96 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "@typeInfo(std.target.Target.Os.VersionRange).Union.tag_type.?", scope: !27, file: !27, line: 225, baseType: !21, size: 8, align: 8, elements: !97)
!97 = !{!98, !99, !100, !101}
!98 = !DIEnumerator(name: "none", value: 0)
!99 = !DIEnumerator(name: "semver", value: 1)
!100 = !DIEnumerator(name: "linux", value: 2)
!101 = !DIEnumerator(name: "windows", value: 3)
!1306 = !{}
!1320 = !DICompositeType(tag: DW_TAG_structure_type, name: "std.target.Target.Os.VersionRange", scope: !27, file: !27, line: 225, size: 320, align: 32, elements: !1321)
!1321 = !{!1322}
!1322 = !DIDerivedType(tag: DW_TAG_member, name: "tag", scope: !1320, file: !27, line: 225, baseType: !96, size: 2, align: 8, offset: 288)
!2251 = distinct !DISubprogram(name: "printTargetArch", scope: !2252, file: !2252, line: 4, type: !2253, scopeLine: 4, flags: DIFlagStaticMember, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !2256)
!2252 = !DIFile(filename: "testme.zig", directory: "/home/topolarity/repos/zig")
!2253 = !DISubroutineType(types: !2254)
!2254 = !{null, !2255}
!2255 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "*std.target.Target", baseType: !1320, size: 64, align: 64)
!2256 = !{!2257}
!2257 = !DILocalVariable(name: "t", arg: 1, scope: !2251, file: !2252, line: 4, type: !1320)
!2258 = !DILocation(line: 5, column: 39, scope: !2259)
!2259 = distinct !DILexicalBlock(scope: !2251, file: !2252, line: 4, column: 40) Reproduce with: $ llc-15 ./reduced.ll.txt -o ./testme.o -filetype=obj
$ ld.lld-15 -o testme ./testme.o
$ lldb testme -o "br set -f testme.zig -l 5" -o "r"
-- crashes LLDB |
Don't know if this is relevant, but it doesn't reproduce on M1 for me.
|
Doesn't reproduce on Intel Mac, either.
|
Can you try The breakpoint + run is required to trigger the crash on my machine |
Sorry, read a bit too fast. It doesn't reproduce on my M1 build, though.
|
But my Intel build crashes!
|
I'm making this the tracking issue for reverting f874b5e |
I just repeated the above LLDB sessions using zig 0.11.0-dev.6038. Both ARM and Intel Macs now work as expected. |
This is my current setup (M1 Max):
Intel MacBook Pro (15-inch, 2018):
|
Zig Version
0.10.0-dev.4115+75e9a8c7f
Steps to Reproduce
Expected Behavior
LLDB should not crash.
Actual Behavior
LLDB crashes.
GDB handles this just fine, so this is likely an upstream bug.
The text was updated successfully, but these errors were encountered: