svn commit: r339898 - head/lib/libc/amd64/sys

From: Charlie Li <ml_at_vishwin.info>
Date: Mon, 5 Nov 2018 21:10:13 -0500
On 03/11/2018 19:45, Konstantin Belousov wrote:
> Or rather, it is a middle of the valid instruction.
> Next frame looks like it is process_irelocs(), if trusting the line
> numbers.  So most likely it is something related to calling wrong
> relocator function, if anything.
> 
> Perhaps you could try to trace the things manually, doing
> single-stepping of the startup code in debugger. There should be very
> modest amount of the irelocs, perhaps only one, and see where things go
> off the way.
> 
After a few more complete buildworlds, including one with all
bootstrapping enabled, this doesn't look compiler-specific. Static
binaries built with the in-tree base LLVM (6.0.1) also crash.

I stepped through bmake with base lldb, comparing the working copy in my
system from circa r339990 with r340173 built with bootstrapped
toolchain. Only the differing parts are shown for conciseness.

Circa r339990:
Process 82271 stopped
* thread #1, name = 'make', stop reason = step over
    frame #0: 0x000000000024ab06 make`_init_tls at tls.c:471
   468          }
   469          tls = _rtld_allocate_tls(NULL, TLS_TCB_SIZE, TLS_TCB_ALIGN);
   470
-> 471          _set_tp(tls);
   472  #endif
   473  }
(lldb) n
Process 82271 stopped
* thread #1, name = 'make', stop reason = step over
    frame #0: 0x0000000000255e60 make`_set_tp(tp=0x00000008002f7830) at
_set_tp.c:38
   35
   36   void
   37   _set_tp(void *tp)
-> 38   {
   39
   40           amd64_set_fsbase(tp);
   41   }
(lldb) s
Process 82271 stopped
* thread #1, name = 'make', stop reason = step in
    frame #0: 0x0000000000255e64 make`_set_tp(tp=0x00000008002f7830) at
_set_tp.c:40
   37   _set_tp(void *tp)
   38   {
   39
-> 40           amd64_set_fsbase(tp);
   41   }
(lldb) s
Process 82271 stopped
* thread #1, name = 'make', stop reason = step in
    frame #0: 0x0000000000256580
make`amd64_set_fsbase(addr=0x00000008002f7830) at amd64_set_fsbase.c:43
   40   #include <machine/specialreg.h>
   41   #include <machine/sysarch.h>
   42   #include <x86/ifunc.h>
-> 43   #include "libc_private.h"
   44
   45   static int
   46   amd64_set_fsbase_cpu(void *addr)
(lldb)

r340173:
Process 22663 stopped
* thread #1, name = 'make', stop reason = step over
    frame #0: 0x0000000000247c96 make`_init_tls at tls.c:471
   468          }
   469          tls = _rtld_allocate_tls(NULL, TLS_TCB_SIZE, TLS_TCB_ALIGN);
   470
-> 471          _set_tp(tls);
   472  #endif
   473  }
(lldb) n
Process 22663 stopped
* thread #1, name = 'make', stop reason = step over
    frame #0: 0x0000000000252eb0 make`_set_tp(tp=0x00000008002ed830) at
_set_tp.c:38
   35
   36   void
   37   _set_tp(void *tp)
-> 38   {
   39
   40           amd64_set_fsbase(tp);
   41   }
(lldb) s
Process 22663 stopped
* thread #1, name = 'make', stop reason = step in
    frame #0: 0x0000000000252eb4 make`_set_tp(tp=0x00000008002ed830) at
_set_tp.c:40
   37   _set_tp(void *tp)
   38   {
   39
-> 40           amd64_set_fsbase(tp);
   41   }
(lldb) s
Process 22663 stopped
* thread #1, name = 'make', stop reason = step in
    frame #0: 0x0000000000252eb5 make`_set_tp(tp=0x00000008002ed830) at
_set_tp.c:40
   37   _set_tp(void *tp)
   38   {
   39
-> 40           amd64_set_fsbase(tp);
   41   }
(lldb) s
Process 22663 stopped
* thread #1, name = 'make', stop reason = step in
    frame #0: 0x00000000002ebdb0 make
->  0x2ebdb0: movq   0x3ce9(%rip), %r11
    0x2ebdb7: callq  0x2ebda0                  ; _fini
    0x2ebdbc: jmp    0x2ebd92                  ; _init + 6
    0x2ebdc1: pushq  $0x0
(lldb) n
Process 22663 stopped
* thread #1, name = 'make', stop reason = instruction step over
    frame #0: 0x00000000002ebdb7 make
->  0x2ebdb7: callq  0x2ebda0                  ; _fini
    0x2ebdbc: jmp    0x2ebd92                  ; _init + 6
    0x2ebdc1: pushq  $0x0
    0x2ebdc6: jmp    0x2ebd80                  ; __do_global_ctors_aux + 48
(lldb) n
Process 22663 stopped
* thread #1, name = 'make', stop reason = instruction step over
    frame #0: 0x00000000002ebda0 make`_fini at crti.S:41
   38           .globl  _fini
   39           .type   _fini,_at_function
   40   _fini:
-> 41           subq    $8,%rsp
   42
   43           .section .note.GNU-stack,"",%progbits
(lldb) n
Process 22663 stopped
* thread #1, name = 'make', stop reason = step over
    frame #0: 0x00000000002ebda4 make`_fini + 4
make`_fini:
->  0x2ebda4 <+4>:  callq  0x226310                  ; __do_global_dtors_aux
    0x2ebda9 <+9>:  addq   $0x8, %rsp
    0x2ebdad <+13>: retq
    0x2ebdae:       addb   %al, (%rax)
(lldb) n
Process 22663 stopped
* thread #1, name = 'make', stop reason = instruction step over
    frame #0: 0x00000000002ebda9 make`_fini at crtn.S:34
   31           ret
   32
   33           .section .fini,"ax",_at_progbits
-> 34           addq    $8,%rsp
   35           ret
   36
   37           .section .note.GNU-stack,"",%progbits
(lldb) n
Process 22663 stopped
* thread #1, name = 'make', stop reason = step over
    frame #0: 0x00000000002ebdad make`_fini at crtn.S:35
   32
   33           .section .fini,"ax",_at_progbits
   34           addq    $8,%rsp
-> 35           ret
   36
   37           .section .note.GNU-stack,"",%progbits
(lldb) n
Process 22663 stopped
* thread #1, name = 'make', stop reason = step over
    frame #0: 0x00000000002ebdbc make
->  0x2ebdbc: jmp    0x2ebd92                  ; _init + 6
    0x2ebdc1: pushq  $0x0
    0x2ebdc6: jmp    0x2ebd80                  ; __do_global_ctors_aux + 48
    0x2ebdcb: int3
(lldb) n
Process 22663 stopped
* thread #1, name = 'make', stop reason = instruction step over
    frame #0: 0x00000000002ebd92 make`_init + 6
make`_init:
->  0x2ebd92 <+6>: movsl  (%rsi), %es:(%rdi)
(lldb) n
Process 22663 stopped
* thread #1, name = 'make', stop reason = signal SIGSEGV: invalid
address (fault address: 0x0)
    frame #0: 0x00000000002ebd92 make`_init + 6
make`_init:
->  0x2ebd92 <+6>: movsl  (%rsi), %es:(%rdi)
(lldb) n
Process 22663 exited with status = -1 (0xffffffff)
(lldb)

-- 
Charlie Li
Can't think of a witty .sigline today…

(This email address is for mailing list use only; replace local-part
with vishwin for off-list communication)




Received on Tue Nov 06 2018 - 01:10:34 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:19 UTC