Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upStd support #146
Comments
bjorn3
added
the
enhancement
label
Nov 13, 2018
bjorn3
added this to the MVP milestone
Nov 16, 2018
bjorn3
removed
the
enhancement
label
Nov 16, 2018
This comment has been minimized.
This comment has been minimized.
|
This is now blocked on #209. |
bjorn3
pinned this issue
Dec 18, 2018
bjorn3
unpinned this issue
Dec 18, 2018
bjorn3
pinned this issue
Dec 19, 2018
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
The segfault happens after returning from Backtrace at the first inst (
Backtrace at the second inst:
Backtrace at the fourth inst:
clif and asm of `try_with`function u0:0(i64, i64, i64) system_v {
ss0 = explicit_slot 0
ss1 = explicit_slot 8
ss2 = explicit_slot 8
ss3 = explicit_slot 8
ss4 = explicit_slot 0
ss5 = explicit_slot 0
ss6 = explicit_slot 0
ss7 = explicit_slot 0
ss8 = explicit_slot 0
ss9 = explicit_slot 0
ss10 = explicit_slot 0
ss11 = explicit_slot 8
ss12 = explicit_slot 8
ss13 = explicit_slot 8
sig0 = (i64) system_v
sig1 = (i64, i64, i64) system_v
sig2 = (i64, i64, i64) system_v
sig3 = (i64, i64) system_v
sig4 = (i64, i64) system_v
sig5 = (i64) -> i64 system_v
sig6 = (i64) -> i64 system_v
sig7 = (i64, i64) system_v
sig8 = (i64, i64) system_v
sig9 = (i64, i64) system_v
sig10 = (i64, i64) system_v
sig11 = (i64, i64) -> i64 system_v
sig12 = (i64, i64) -> i64 system_v
sig13 = (i64, i64) system_v
sig14 = (i64, i64) system_v
fn0 = colocated u0:3591 sig2
fn1 = u0:3592 sig4
fn2 = u0:2722 sig6
fn3 = u0:233 sig8
fn4 = u0:3999 sig10
fn5 = u0:3594 sig12
fn6 = u0:4306 sig14
jt0 = jump_table [ebb6, ebb7]
jt1 = jump_table [ebb12, ebb13]
ebb0(v0: i64, v1: i64, v2: i64):
v17 -> v1
v46 -> v1
v37 -> v46
nop
; ssa {_20: NOT_SSA, _3: (empty), _25: (empty), _11: (empty), _0: NOT_SSA, _1: (empty), _23: (empty), _10: NOT_SSA, _18: (empty), _8: NOT_SSA, _5: NOT_SSA, _4: NOT_SSA, _6: NOT_SSA, _26: (empty), _21: (empty), _2: NOT_SSA, _7: (empty), _12: (empty), _22: (empty), _13: NOT_SSA, _17: NOT_SSA, _15: NOT_SSA, _19: (empty), _9: NOT_SSA, _14: NOT_SSA, _16: NOT_SSA, _24: NOT_SSA}
; pass _1: &thread::local::LocalKey<core::cell::RefCell<core::option::Option<sys_common::thread_info::ThreadInfo>>> ByVal(types::I64)
; pass _2: [closure@sysroot_src/src/libstd/sys_common/thread_info.rs:47:22: 47:55] ByRef
v3 = stack_addr.i64 ss0
v4 = stack_addr.i64 ss1
v5 = stack_addr.i64 ss2
v6 = stack_addr.i64 ss3
v7 = stack_addr.i64 ss4
v8 = stack_addr.i64 ss5
v9 = stack_addr.i64 ss6
v10 = stack_addr.i64 ss7
v11 = stack_addr.i64 ss8
v12 = stack_addr.i64 ss9
v13 = stack_addr.i64 ss10
v14 = stack_addr.i64 ss11
v15 = stack_addr.i64 ss12
v16 = stack_addr.i64 ss13
jump ebb1
ebb1:
nop
; _7 = ((*_1).0: unsafe fn() -> core::option::Option<&core::cell::UnsafeCell<core::option::Option<T>>>)
v18 = load.i64 v17
;
; _6 = move _7()
call_indirect sig0, v18(v6)
jump ebb2
ebb2:
nop
; (_8.0: ()) = move _9
;
; _5 = const <core::option::Option<T>>::ok_or(move _6, move _8)
call fn0(v5, v6, v7)
jump ebb3
ebb3:
nop
;
; _4 = const core::ops::Try::into_result(move _5)
call fn1(v4, v5)
jump ebb4
ebb4:
nop
; _12 = discriminant(_4)
v19 = load.i64 v4
v20 = icmp_imm eq v19, 0
v21 = iconst.i64 1
v22 = iconst.i64 0
v23 = select v20, v21, v22
;
; switchInt(move _12)
v24 = icmp_imm uge v23, 0
brnz v24, ebb17
jump ebb5
ebb17:
v25 = iadd_imm.i64 v23, 0
br_table v25, ebb5, jt0
ebb5:
nop
;
; unreachable
trap user65535
ebb6:
nop
; _11 = ((_4 as Ok).0: &core::cell::UnsafeCell<core::option::Option<T>>)
v26 = load.i64 v4
v47 -> v26
v38 -> v47
; _3 = _11
; _16 = move _2
; _21 = _3
;
; _20 = const <core::cell::UnsafeCell<T>>::get(move _21)
v27 = call fn2(v26)
store v27, v15
jump ebb11
ebb7:
nop
; _10 = move ((_4 as Err).0: thread::local::AccessError)
; _14 = move _10
;
; _13 = const core::convert::From::from(move _14)
call fn3(v10, v11)
jump ebb8
ebb8:
nop
;
; _0 = const core::ops::Try::from_error(move _13)
call fn4(v0, v10)
jump ebb9
ebb9:
nop
;
; drop(_2)
jump ebb10
ebb10:
nop
;
; return
return
ebb11:
nop
; _23 = discriminant((*_20))
v28 = load.i64 v15
v29 = iadd_imm v28, 8
v30 = load.i64 v29
v31 = icmp_imm eq v30, 3
v32 = iconst.i64 0
v33 = iconst.i64 1
v34 = select v31, v32, v33
;
; switchInt(move _23)
v35 = icmp_imm uge v34, 0
brnz v35, ebb18
jump ebb5
ebb18:
v36 = iadd_imm.i64 v34, 0
br_table v36, ebb5, jt1
ebb12:
nop
; _25 = _1
; _26 = _3
;
; _24 = const <thread::local::LocalKey<T>>::init(move _25, move _26)
v39 = call fn5(v37, v38)
store v39, v16
jump ebb15
ebb13:
nop
; _22 = &(((*_20) as Some).0: T)
v40 = load.i64 v15
; _19 = _22
;
; goto
jump ebb14(v40)
ebb14(v41: i64):
nop
; _18 = _19
; (_17.0: &T) = move _18
store v41, v14
;
; _15 = const core::ops::FnOnce::call_once(move _16, move _17)
v42 = load.i64 v14
call fn6(v13, v42)
jump ebb16
ebb15:
nop
; _19 = _24
v43 = load.i64 v16
;
; goto
jump ebb14(v43)
ebb16:
nop
; ((_0 as Ok).0: R) = move _15
v44 = iadd_imm.i64 v0, 1
; discriminant(_0) = 0
v45 = iconst.i8 0
store v45, v0
;
; goto
jump ebb10
}0000000000023200 <_ZN46_$LT$std..thread..local..LocalKey$LT$T$GT$$GT$8try_with17h36cfa393b9d2739bE>:
23200: 40 55 rex push %rbp
23202: 48 89 e5 mov %rsp,%rbp
23205: 48 81 ec a0 00 00 00 sub $0xa0,%rsp
2320c: 48 89 bc 24 68 00 00 mov %rdi,0x68(%rsp)
23213: 00
23214: 48 89 b4 24 60 00 00 mov %rsi,0x60(%rsp)
2321b: 00
2321c: 48 8d 84 24 00 00 00 lea 0x0(%rsp),%rax
23223: 00
23224: 48 8d 84 24 98 00 00 lea 0x98(%rsp),%rax
2322b: 00
2322c: 48 89 84 24 58 00 00 mov %rax,0x58(%rsp)
23233: 00
23234: 48 8d 84 24 90 00 00 lea 0x90(%rsp),%rax
2323b: 00
2323c: 48 89 84 24 50 00 00 mov %rax,0x50(%rsp)
23243: 00
23244: 48 8d 84 24 88 00 00 lea 0x88(%rsp),%rax
2324b: 00
2324c: 48 89 84 24 48 00 00 mov %rax,0x48(%rsp)
23253: 00
23254: 48 8d 84 24 00 00 00 lea 0x0(%rsp),%rax
2325b: 00
2325c: 48 89 84 24 40 00 00 mov %rax,0x40(%rsp)
23263: 00
23264: 48 8d 84 24 00 00 00 lea 0x0(%rsp),%rax
2326b: 00
2326c: 48 8d 84 24 00 00 00 lea 0x0(%rsp),%rax
23273: 00
23274: 48 8d 84 24 00 00 00 lea 0x0(%rsp),%rax
2327b: 00
2327c: 48 89 84 24 38 00 00 mov %rax,0x38(%rsp)
23283: 00
23284: 48 8d 84 24 00 00 00 lea 0x0(%rsp),%rax
2328b: 00
2328c: 48 89 84 24 30 00 00 mov %rax,0x30(%rsp)
23293: 00
23294: 48 8d 84 24 00 00 00 lea 0x0(%rsp),%rax
2329b: 00
2329c: 48 8d 84 24 00 00 00 lea 0x0(%rsp),%rax
232a3: 00
232a4: 48 89 84 24 28 00 00 mov %rax,0x28(%rsp)
232ab: 00
232ac: 48 8d 84 24 80 00 00 lea 0x80(%rsp),%rax
232b3: 00
232b4: 48 89 84 24 20 00 00 mov %rax,0x20(%rsp)
232bb: 00
232bc: 48 8d 84 24 78 00 00 lea 0x78(%rsp),%rax
232c3: 00
232c4: 48 89 84 24 18 00 00 mov %rax,0x18(%rsp)
232cb: 00
232cc: 48 8d 84 24 70 00 00 lea 0x70(%rsp),%rax
232d3: 00
232d4: 48 89 84 24 10 00 00 mov %rax,0x10(%rsp)
232db: 00
232dc: 48 8b 84 24 60 00 00 mov 0x60(%rsp),%rax
232e3: 00
232e4: 48 8b 00 mov (%rax),%rax
232e7: 48 8b 8c 24 48 00 00 mov 0x48(%rsp),%rcx
232ee: 00
232ef: 48 89 cf mov %rcx,%rdi
232f2: 40 ff d0 rex callq *%rax
232f5: 48 8b 84 24 50 00 00 mov 0x50(%rsp),%rax
232fc: 00
232fd: 48 8b 8c 24 48 00 00 mov 0x48(%rsp),%rcx
23304: 00
23305: 48 8b 94 24 40 00 00 mov 0x40(%rsp),%rdx
2330c: 00
2330d: 48 89 c7 mov %rax,%rdi
23310: 48 89 ce mov %rcx,%rsi
23313: e8 f8 01 00 00 callq 23510 <_ZN38_$LT$core..option..Option$LT$T$GT$$GT$5ok_or17hc08dcc56df316dd4E>
23318: 48 8b 84 24 58 00 00 mov 0x58(%rsp),%rax
2331f: 00
23320: 48 8b 8c 24 50 00 00 mov 0x50(%rsp),%rcx
23327: 00
23328: 48 89 c7 mov %rax,%rdi
2332b: 48 89 ce mov %rcx,%rsi
2332e: e8 0d 03 00 00 callq 23640 <_ZN78_$LT$core..result..Result$LT$T$C$$u20$E$GT$$u20$as$u20$core..ops..try..Try$GT$11into_result17h020ad5f0907363fdE>
23333: 48 8b 84 24 58 00 00 mov 0x58(%rsp),%rax
2333a: 00
2333b: 48 8b 00 mov (%rax),%rax
2333e: 48 83 f8 00 cmp $0x0,%rax
23342: 0f 94 c0 sete %al
23345: 40 b9 01 00 00 00 rex mov $0x1,%ecx
2334b: 40 ba 00 00 00 00 rex mov $0x0,%edx
23351: 40 84 c0 test %al,%al
23354: 75 06 jne 2335c <_ZN46_$LT$std..thread..local..LocalKey$LT$T$GT$$GT$8try_with17h36cfa393b9d2739bE+0x15c>
23356: 48 89 d0 mov %rdx,%rax
23359: 48 89 c1 mov %rax,%rcx
2335c: 48 83 f9 00 cmp $0x0,%rcx
23360: 0f 93 c0 setae %al
23363: 40 84 c0 test %al,%al
23366: 75 03 jne 2336b <_ZN46_$LT$std..thread..local..LocalKey$LT$T$GT$$GT$8try_with17h36cfa393b9d2739bE+0x16b>
23368: 40 eb 21 rex jmp 2338c <_ZN46_$LT$std..thread..local..LocalKey$LT$T$GT$$GT$8try_with17h36cfa393b9d2739bE+0x18c>
2336b: 48 83 c1 00 add $0x0,%rcx
2336f: 48 83 f9 02 cmp $0x2,%rcx
23373: 0f 93 c0 setae %al
23376: 40 84 c0 test %al,%al
23379: 75 11 jne 2338c <_ZN46_$LT$std..thread..local..LocalKey$LT$T$GT$$GT$8try_with17h36cfa393b9d2739bE+0x18c>
2337b: 48 8d 05 79 01 00 00 lea 0x179(%rip),%rax # 234fb <_ZN46_$LT$std..thread..local..LocalKey$LT$T$GT$$GT$8try_with17h36cfa393b9d2739bE+0x2fb>
23382: 48 63 0c 88 movslq (%rax,%rcx,4),%rcx
23386: 48 01 c8 add %rcx,%rax
23389: 40 ff e0 rex jmpq *%rax
2338c: 0f 0b ud2
2338e: 48 8b 84 24 58 00 00 mov 0x58(%rsp),%rax
23395: 00
23396: 48 8b 00 mov (%rax),%rax
23399: 48 89 84 24 08 00 00 mov %rax,0x8(%rsp)
233a0: 00
233a1: 48 8b 84 24 08 00 00 mov 0x8(%rsp),%rax
233a8: 00
233a9: 48 89 c7 mov %rax,%rdi
233ac: e8 7f 83 ff ff callq 1b730 <_ZN40_$LT$core..cell..UnsafeCell$LT$T$GT$$GT$3get17hdeb583042ffbf290E>
233b1: 48 8b 8c 24 18 00 00 mov 0x18(%rsp),%rcx
233b8: 00
233b9: 48 89 01 mov %rax,(%rcx)
233bc: 40 eb 40 rex jmp 233ff <_ZN46_$LT$std..thread..local..LocalKey$LT$T$GT$$GT$8try_with17h36cfa393b9d2739bE+0x1ff>
233bf: 48 8b 84 24 38 00 00 mov 0x38(%rsp),%rax
233c6: 00
233c7: 48 8b 8c 24 30 00 00 mov 0x30(%rsp),%rcx
233ce: 00
233cf: 48 89 c7 mov %rax,%rdi
233d2: 48 89 ce mov %rcx,%rsi
233d5: e8 26 4c ff ff callq 18000 <_ZN50_$LT$T$u20$as$u20$core..convert..From$LT$T$GT$$GT$4from17h9bd35ba97d141524E>
233da: 48 8b 84 24 68 00 00 mov 0x68(%rsp),%rax
233e1: 00
233e2: 48 8b 8c 24 38 00 00 mov 0x38(%rsp),%rcx
233e9: 00
233ea: 48 89 c7 mov %rax,%rdi
233ed: 48 89 ce mov %rcx,%rsi
233f0: e8 1b 4c ff ff callq 18010 <_ZN78_$LT$core..result..Result$LT$T$C$$u20$E$GT$$u20$as$u20$core..ops..try..Try$GT$10from_error17h39d75f165c72b959E>
233f5: 48 81 c4 a0 00 00 00 add $0xa0,%rsp
233fc: 40 5d rex pop %rbp
233fe: c3 retq
233ff: 48 8b 84 24 18 00 00 mov 0x18(%rsp),%rax
23406: 00
23407: 48 8b 00 mov (%rax),%rax
2340a: 48 83 c0 08 add $0x8,%rax
2340e: 48 8b 00 mov (%rax),%rax
23411: 48 83 f8 03 cmp $0x3,%rax
23415: 0f 94 c0 sete %al
23418: 40 b9 00 00 00 00 rex mov $0x0,%ecx
2341e: 40 ba 01 00 00 00 rex mov $0x1,%edx
23424: 40 84 c0 test %al,%al
23427: 75 06 jne 2342f <_ZN46_$LT$std..thread..local..LocalKey$LT$T$GT$$GT$8try_with17h36cfa393b9d2739bE+0x22f>
23429: 48 89 d0 mov %rdx,%rax
2342c: 48 89 c1 mov %rax,%rcx
2342f: 48 83 f9 00 cmp $0x0,%rcx
23433: 0f 93 c0 setae %al
23436: 40 84 c0 test %al,%al
23439: 75 06 jne 23441 <_ZN46_$LT$std..thread..local..LocalKey$LT$T$GT$$GT$8try_with17h36cfa393b9d2739bE+0x241>
2343b: 40 e9 4b ff ff ff rex jmpq 2338c <_ZN46_$LT$std..thread..local..LocalKey$LT$T$GT$$GT$8try_with17h36cfa393b9d2739bE+0x18c>
23441: 48 83 c1 00 add $0x0,%rcx
23445: 48 83 f9 02 cmp $0x2,%rcx
23449: 0f 93 c0 setae %al
2344c: 40 84 c0 test %al,%al
2344f: 0f 85 37 ff ff ff jne 2338c <_ZN46_$LT$std..thread..local..LocalKey$LT$T$GT$$GT$8try_with17h36cfa393b9d2739bE+0x18c>
23455: 48 8d 05 a7 00 00 00 lea 0xa7(%rip),%rax # 23503 <_ZN46_$LT$std..thread..local..LocalKey$LT$T$GT$$GT$8try_with17h36cfa393b9d2739bE+0x303>
2345c: 48 63 0c 88 movslq (%rax,%rcx,4),%rcx
23460: 48 01 c8 add %rcx,%rax
23463: 40 ff e0 rex jmpq *%rax
23466: 48 8b 84 24 60 00 00 mov 0x60(%rsp),%rax
2346d: 00
2346e: 48 8b 8c 24 08 00 00 mov 0x8(%rsp),%rcx
23475: 00
23476: 48 89 c7 mov %rax,%rdi
23479: 48 89 ce mov %rcx,%rsi
2347c: e8 ef 01 00 00 callq 23670 <_ZN46_$LT$std..thread..local..LocalKey$LT$T$GT$$GT$4init17h46b41a9e98f5bef7E>
23481: 48 8b 8c 24 10 00 00 mov 0x10(%rsp),%rcx
23488: 00
23489: 48 89 01 mov %rax,(%rcx)
2348c: 40 eb 37 rex jmp 234c6 <_ZN46_$LT$std..thread..local..LocalKey$LT$T$GT$$GT$8try_with17h36cfa393b9d2739bE+0x2c6>
2348f: 48 8b 84 24 18 00 00 mov 0x18(%rsp),%rax
23496: 00
23497: 48 8b 00 mov (%rax),%rax
2349a: 48 8b 8c 24 20 00 00 mov 0x20(%rsp),%rcx
234a1: 00
234a2: 48 89 01 mov %rax,(%rcx)
234a5: 48 8b 84 24 20 00 00 mov 0x20(%rsp),%rax
234ac: 00
234ad: 48 8b 00 mov (%rax),%rax
234b0: 48 8b 8c 24 28 00 00 mov 0x28(%rsp),%rcx
234b7: 00
234b8: 48 89 cf mov %rcx,%rdi
234bb: 48 89 c6 mov %rax,%rsi
234be: e8 2d d5 fe ff callq 109f0 <_ZN3std10sys_common11thread_info3set28_$u7b$$u7b$closure$u7d$$u7d$17h70f50255323bfa80E>
234c3: 40 eb 0e rex jmp 234d4 <_ZN46_$LT$std..thread..local..LocalKey$LT$T$GT$$GT$8try_with17h36cfa393b9d2739bE+0x2d4>
234c6: 48 8b 84 24 10 00 00 mov 0x10(%rsp),%rax
234cd: 00
234ce: 48 8b 00 mov (%rax),%rax
234d1: 40 eb c6 rex jmp 2349a <_ZN46_$LT$std..thread..local..LocalKey$LT$T$GT$$GT$8try_with17h36cfa393b9d2739bE+0x29a>
234d4: 48 8b 84 24 68 00 00 mov 0x68(%rsp),%rax
234db: 00
234dc: 48 83 c0 01 add $0x1,%rax
234e0: 40 b8 00 00 00 00 rex mov $0x0,%eax
234e6: 40 0f b6 c0 movzbl %al,%eax
234ea: 48 8b 8c 24 68 00 00 mov 0x68(%rsp),%rcx
234f1: 00
234f2: 40 88 01 mov %al,(%rcx)
234f5: 40 e9 fa fe ff ff rex jmpq 233f5 <_ZN46_$LT$std..thread..local..LocalKey$LT$T$GT$$GT$8try_with17h36cfa393b9d2739bE+0x1f5>
234fb: 93 xchg %eax,%ebx
234fc: fe (bad)
234fd: ff (bad)
234fe: ff c4 inc %esp
23500: fe (bad)
23501: ff (bad)
23502: ff 63 ff jmpq *-0x1(%rbx)
23505: ff (bad)
23506: ff 8c ff ff ff 0f 1f decl 0x1f0fffff(%rdi,%rdi,8)
2350d: 44 00 00 add %r8b,(%rax)cc @sunfishcode (I believe this is a miscompilation from cranelift) |
This comment has been minimized.
This comment has been minimized.
|
One thing I noticed is that cranelift emits a |
This comment has been minimized.
This comment has been minimized.
|
Every single function created by cranelift has the backtrace behavior described above: $ gdb target/out/mini_core_hello_world # a non crashing program
(gdb) break main
Breakpoint 1 at 0x1c40
(gdb) run
Starting program: /home/bjorn/Documenten/rustc_codegen_cranelift/target/out/mini_core_hello_world
Breakpoint 1, 0x0000555555555c40 in main ()
(gdb) disassemble
Dump of assembler code for function main:
=> 0x0000555555555c40 <+0>: rex push %rbp
0x0000555555555c42 <+2>: mov %rsp,%rbp
0x0000555555555c45 <+5>: lea -0xf3c(%rip),%rax # 0x555555554d10 <_ZN21mini_core_hello_world4main17he1655d58f9d91204E>
0x0000555555555c4c <+12>: mov %rsi,%rdx
0x0000555555555c4f <+15>: mov %rdi,%rsi
0x0000555555555c52 <+18>: mov %rax,%rdi
0x0000555555555c55 <+21>: callq 0x555555554b10 <_ZN21mini_core_hello_world5start17h1e715bf6fab28115E>
0x0000555555555c5a <+26>: rex pop %rbp
0x0000555555555c5c <+28>: retq
End of assembler dump.
(gdb) si 7
0x0000555555554b10 in mini_core_hello_world::start::h1e715bf6fab28115 ()
(gdb) disassemble
Dump of assembler code for function _ZN21mini_core_hello_world5start17h1e715bf6fab28115E:
=> 0x0000555555554b10 <+0>: rex push %rbp
0x0000555555554b12 <+2>: mov %rsp,%rbp
0x0000555555554b15 <+5>: sub $0x20,%rsp
0x0000555555554b19 <+9>: lea 0x1c(%rsp),%rax
0x0000555555554b21 <+17>: mov %rax,0x8(%rsp)
0x0000555555554b29 <+25>: lea 0x0(%rsp),%rax
0x0000555555554b31 <+33>: mov %rax,0x10(%rsp)
0x0000555555554b39 <+41>: rex callq *%rdi
0x0000555555554b3c <+44>: mov 0x10(%rsp),%rax
0x0000555555554b44 <+52>: mov %rax,%rdi
0x0000555555554b47 <+55>: callq 0x555555554b70 <_ZN63_$LT$$LP$$RP$$u20$as$u20$mini_core_hello_world..Termination$GT$6report17hdb0778df210e78ccE>
0x0000555555554b4c <+60>: mov 0x8(%rsp),%rcx
0x0000555555554b54 <+68>: rex mov %eax,(%rcx)
0x0000555555554b57 <+71>: mov 0x8(%rsp),%rax
0x0000555555554b5f <+79>: rex mov (%rax),%eax
0x0000555555554b62 <+82>: movslq %eax,%rax
0x0000555555554b65 <+85>: add $0x20,%rsp
0x0000555555554b69 <+89>: rex pop %rbp
0x0000555555554b6b <+91>: retq
End of assembler dump.
(gdb) bt
#0 0x0000555555554b10 in mini_core_hello_world::start::h1e715bf6fab28115 ()
#1 0x0000555555555c5a in main ()
(gdb) si
0x0000555555554b12 in mini_core_hello_world::start::h1e715bf6fab28115 ()
(gdb) bt
#0 0x0000555555554b12 in mini_core_hello_world::start::h1e715bf6fab28115 ()
#1 0x00007fffffffdd80 in ?? ()
#2 0x0000555555555c5a in main ()
(gdb) si
0x0000555555554b15 in mini_core_hello_world::start::h1e715bf6fab28115 ()
(gdb) bt
#0 0x0000555555554b15 in mini_core_hello_world::start::h1e715bf6fab28115 ()
#1 0x00007fffffffdd80 in ?? ()
#2 0x0000555555555c5a in main ()
(gdb) si
0x0000555555554b19 in mini_core_hello_world::start::h1e715bf6fab28115 ()
(gdb) bt
#0 0x0000555555554b19 in mini_core_hello_world::start::h1e715bf6fab28115 ()
#1 0x0000000000000000 in ?? ()I suspect there is a stack alignment problem. (didn't investigate it though) |
This comment has been minimized.
This comment has been minimized.
|
I am almost sure the problem of at least gdb backtraces is stack alignment. While gcc always does Edit: filled CraneStation/cranelift#630 |
This comment has been minimized.
This comment has been minimized.
|
The extra I think the reason why GCC does x*16+8 is that it's doing frame-pointer elimination, so it needs the extra +8 to compensate for the space where the frame pointer would have been pushed. Cranelift currently always pushes the frame pointer, so it doesn't need the extra +8. Can you test whether %rsp is actually misaligned within the body? |
This comment has been minimized.
This comment has been minimized.
|
First: oops meant rustc + llvm not gcc :) rustc: 0000000000005dc0 <_ZN11simple_main4main17hb13a4a470fc2f2b2E>:
5dc0: 48 83 ec 38 sub $0x38,%rsp
5dc4: 48 8d 05 ed 93 22 00 lea 0x2293ed(%rip),%rax # 22f1b8 <__JCR_END__+0x8>
5dcb: 48 8d 0d 46 fe 01 00 lea 0x1fe46(%rip),%rcx # 25c18 <_fini+0x14>
5dd2: 31 d2 xor %edx,%edx
5dd4: 41 89 d0 mov %edx,%r8d
5dd7: 48 8d 7c 24 08 lea 0x8(%rsp),%rdi
5ddc: 48 89 c6 mov %rax,%rsi
5ddf: ba 01 00 00 00 mov $0x1,%edx
5de4: e8 37 01 00 00 callq 5f20 <_ZN4core3fmt9Arguments6new_v117h5ae58c641f8553b9E>
5de9: 48 8d 7c 24 08 lea 0x8(%rsp),%rdi
5dee: ff 15 9c af 22 00 callq *0x22af9c(%rip) # 230d90 <_GLOBAL_OFFSET_TABLE_+0x310>
5df4: 48 83 c4 38 add $0x38,%rsp
5df8: c3 retq
5df9: 0f 1f 80 00 00 00 00 nopl 0x0(%rax)cranelift: 4120: 40 55 rex push %rbp
4122: 48 89 e5 mov %rsp,%rbp
4125: 48 81 ec 90 00 00 00 sub $0x90,%rsp
412c: 40 b8 00 00 00 00 rex mov $0x0,%eax
4132: 48 8d 84 24 88 00 00 lea 0x88(%rsp),%rax
4139: 00
413a: 48 89 84 24 70 00 00 mov %rax,0x70(%rsp)
4141: 00
4142: 48 8d 84 24 80 00 00 lea 0x80(%rsp),%rax
[...]Second:
Seems the stack is aligned after all. |
This comment has been minimized.
This comment has been minimized.
|
I am still puzzled by the gdb backtraces though. |
This comment has been minimized.
This comment has been minimized.
|
Oh, it's possible that gdb is trying to parse the prologue and getting confused by the rex prefixes. Let me investigate a little more. |
This comment has been minimized.
This comment has been minimized.
Thanks |
This comment has been minimized.
This comment has been minimized.
|
Yes, that looks like it. You can see it in a simple .s file like this: .globl foo
foo:
rex push %rbp
mov %rsp,%rbp
sub $0x20,%rsp
nop
add $0x20,%rsp
pop %rbp
retqgdb has trouble printing back traces in the middle of this function, and removing the rex prefix fixes it. |
This comment has been minimized.
This comment has been minimized.
|
It looks like opt_level=best is a workaround, as that enables the shrink pass which eliminates the rex prefix. But that's just a workaound, of course we'll want to fix it so that we always avoid the rex prefix so that backtraces work. |
This comment has been minimized.
This comment has been minimized.
Rebuilding sysroot with |
This comment has been minimized.
This comment has been minimized.
|
Yes, it fixes the backtraces |
This comment has been minimized.
This comment has been minimized.
|
Found the corrupting instruction. I don't know why it does corrupt though.
|
This comment has been minimized.
This comment has been minimized.
|
Is it possible that the store to 0x18(%rdi) is somehow clobbering a return address on the stack? |
This comment has been minimized.
This comment has been minimized.
|
That's possible.
|
This comment has been minimized.
This comment has been minimized.
Edit: 0x58 + 0x18 = 0x70 which is bigger than 0x68. This seems to be the problem indeed. |
bjorn3
self-assigned this
Dec 23, 2018
bjorn3
added
the
bug
label
Dec 23, 2018
This comment has been minimized.
This comment has been minimized.
|
I was able to work around this in d3dcf4d. |
This comment has been minimized.
This comment has been minimized.
|
I am trying to compile ripgrep using this at the moment. Some build scripts fail, because of code replaced with |
bjorn3
added
the
help wanted
label
Jan 31, 2019
This comment was marked as resolved.
This comment was marked as resolved.
|
Status report: For https://github.com/dropbox/rust-brotli-decompressor I get the following on Linux:
Note: use lldb or rr, because gdb crashes itself. |
This comment has been minimized.
This comment has been minimized.
|
Note to self: I need to promote any argument smaller than a C int to an int, and promote float to double. (Source: https://github.com/rust-lang/rfcs/blob/master/text/2137-variadic.md) |
This comment was marked as resolved.
This comment was marked as resolved.
|
The |
This comment was marked as resolved.
This comment was marked as resolved.
|
I found a problem: storing a func ptr in a zero sized stack slot. That stack slot was probably meant for [...]
ss4 = explicit_slot 0
[...]
; _1 = const <std::result::Result<T, E>>::map(move _2, const std::prelude::v1::Some)
@0000 v6 = func_addr.i64 fn0
@0000 v7 = load.i8 v2
@0000 v8 = stack_addr.i64 ss4
[...] |
This comment was marked as resolved.
This comment was marked as resolved.
|
Fixed it in 0d16dcf |
This comment has been minimized.
This comment has been minimized.
|
Things crashing:
|
bjorn3 commentedNov 13, 2018
•
edited
Unimplemented stuff
Edit: hiding this because it is fixed in 1717cc4
Edit2: Patched out variadic functions