How to deal with a kernel panic

I am trying the latest master version of upstream redox-os and it compiles fine. When I run make qemu I get a choice of display and when choosing the VM freezes. The kernel shows:

BSP: Ok(ContextId(1)) 4
Page fault: 14:0000000000000000 at 23:0000000000000000
TRACE: FFFFFF40000110E0
  FFFFFF40000110E0: FFFFFF0000149F3E
  FFFFFF4000011170: FFFFFF0000148781
  FFFFFF4000011258: FFFFFF000014290E
  FFFFFF40000112F8: 003A736674696E69
  0000000000000000: GUARD PAGE
SIGNAL 11, CPU 0, PID ContextId(2)
NAME initfs:/bin/init
ContextId(0) not found for exit vfork unblock

I am an experienced developer with marchinal kernel/rust/redox experience. Can I get a pointer on how to address this issue? Where to look first, at code, in logs? at first glance some stack is dropped one time more often then popped, …?

Issues like this usually come from getting an improper build. One thing you can try is to download the latest harddrive release: https://github.com/redox-os/redox/releases/download/0.0.6/harddrive.bin.gz, gunzip it, and run it with qemu.

To make sure you have a correct build, I would like to know the following from your system:

uname -a

rustc -V

gcc -v

please note that I updated from upstream and it worked yesterday/this morning. so here they come:

[dahn@blimbing redox]$ uname -a
Linux blimbing.onecht.net 4.8.13-300.fc25.x86_64 #1 SMP Fri Dec 9 14:52:00 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
[dahn@blimbing redox]$ rustc -V
rustc 1.16.0-nightly (468227129 2017-01-03)
[dahn@blimbing redox]$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --disable-libgcj --with-isl --enable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 6.3.1 20161221 (Red Hat 6.3.1-1) (GCC) 

So - In that time potentially the change to cargo workspaces broke your build.

Try doing:

make clean
make initfs/bin/init

Then give me the results of:
readelf -hlS initfs/bin/init

ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x410f10
  Start of program headers:          64 (bytes into file)
  Start of section headers:          106944 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         9
  Size of section headers:           64 (bytes)
  Number of section headers:         21
  Section header string table index: 20

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .interp           PROGBITS         0000000000400238  00000238
       000000000000000f  0000000000000000   A       0     0     1
  [ 2] .note.gnu.build-i NOTE             0000000000400248  00000248
       0000000000000024  0000000000000000   A       0     0     4
  [ 3] .gnu.hash         GNU_HASH         0000000000400270  00000270
       000000000000001c  0000000000000000   A       4     0     8
  [ 4] .dynsym           DYNSYM           0000000000400290  00000290
       0000000000000120  0000000000000018   A       5     1     8
  [ 5] .dynstr           STRTAB           00000000004003b0  000003b0
       000000000000006f  0000000000000000   A       0     0     1
  [ 6] .gnu.version      VERSYM           0000000000400420  00000420
       0000000000000018  0000000000000002   A       4     0     2
  [ 7] .gnu.version_r    VERNEED          0000000000400438  00000438
       0000000000000030  0000000000000000   A       5     1     8
  [ 8] .rela.plt         RELA             0000000000400468  00000468
       0000000000000108  0000000000000018  AI       4    16     8
  [ 9] .plt              PROGBITS         0000000000400570  00000570
       00000000000000c0  0000000000000010  AX       0     0     16
  [10] .text             PROGBITS         0000000000400630  00000630
       0000000000010993  0000000000000000  AX       0     0     16
  [11] .rodata           PROGBITS         0000000000410fd0  00010fd0
       0000000000006688  0000000000000000   A       0     0     16
  [12] .eh_frame         X86_64_UNWIND    0000000000417658  00017658
       00000000000018f0  0000000000000000   A       0     0     8
  [13] .tdata            PROGBITS         0000000000619e08  00019e08
       00000000000000b8  0000000000000000 WAT       0     0     8
  [14] .tbss             NOBITS           0000000000619ec0  00019ec0
       0000000000000008  0000000000000000 WAT       0     0     8
  [15] .dynamic          DYNAMIC          0000000000619ec0  00019ec0
       0000000000000140  0000000000000010  WA       5     0     8
  [16] .got.plt          PROGBITS         000000000061a000  0001a000
       0000000000000070  0000000000000008  WA       0     0     8
  [17] .data             PROGBITS         000000000061a070  0001a070
       0000000000000048  0000000000000000  WA       0     0     8
  [18] .bss              NOBITS           000000000061a0b8  0001a0b8
       0000000000000048  0000000000000000  WA       0     0     8
  [19] .comment          PROGBITS         0000000000000000  0001a0b8
       0000000000000055  0000000000000001  MS       0     0     1
  [20] .shstrtab         STRTAB           0000000000000000  0001a10d
       00000000000000b1  0000000000000000           0     0     1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings), l (large)
  I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  PHDR           0x0000000000000040 0x0000000000400040 0x0000000000400040
                 0x00000000000001f8 0x00000000000001f8  R E    8
  INTERP         0x0000000000000238 0x0000000000400238 0x0000000000400238
                 0x000000000000000f 0x000000000000000f  R      1
      [Requesting program interpreter: /lib/ld64.so.1]
  LOAD           0x0000000000000000 0x0000000000400000 0x0000000000400000
                 0x0000000000018f48 0x0000000000018f48  R E    200000
  LOAD           0x0000000000019e08 0x0000000000619e08 0x0000000000619e08
                 0x00000000000002b0 0x00000000000002f8  RW     200000
  DYNAMIC        0x0000000000019ec0 0x0000000000619ec0 0x0000000000619ec0
                 0x0000000000000140 0x0000000000000140  RW     8
  NOTE           0x0000000000000248 0x0000000000400248 0x0000000000400248
                 0x0000000000000024 0x0000000000000024  R      4
  TLS            0x0000000000019e08 0x0000000000619e08 0x0000000000619e08
                 0x00000000000000b8 0x00000000000000c0  R      8
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RW     10
  GNU_RELRO      0x0000000000019e08 0x0000000000619e08 0x0000000000619e08
                 0x00000000000001f8 0x00000000000001f8  R      1

 Section to Segment mapping:
  Segment Sections...
   00     
   01     .interp 
   02     .interp .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.plt .plt .text .rodata .eh_frame 
   03     .tdata .dynamic .got.plt .data .bss 
   04     .dynamic 
   05     .note.gnu.build-id 
   06     .tdata .tbss 
   07     
   08     .tdata .dynamic 

It looks different, not sure why.

Your GCC and Rust look similar to mine. I am on Ubuntu, but I would expect them to operate the same way.

I have gcc 6.2.0, perhaps that causes the difference in behavior.

I’ll see if I can downgrade (or install the older version in parallel) I can only see a 6.2.1 package so I’ll try that one, otherwise I’ll have to compile version 6.2.0 first

with gcc 6.2.1:

[dahn@blimbing redox]$ readelf -hlS initfs/bin/init
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x410f10
  Start of program headers:          64 (bytes into file)
  Start of section headers:          106944 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         9
  Size of section headers:           64 (bytes)
  Number of section headers:         21
  Section header string table index: 20

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .interp           PROGBITS         0000000000400238  00000238
       000000000000000f  0000000000000000   A       0     0     1
  [ 2] .note.gnu.build-i NOTE             0000000000400248  00000248
       0000000000000024  0000000000000000   A       0     0     4
  [ 3] .gnu.hash         GNU_HASH         0000000000400270  00000270
       000000000000001c  0000000000000000   A       4     0     8
  [ 4] .dynsym           DYNSYM           0000000000400290  00000290
       0000000000000120  0000000000000018   A       5     1     8
  [ 5] .dynstr           STRTAB           00000000004003b0  000003b0
       000000000000006f  0000000000000000   A       0     0     1
  [ 6] .gnu.version      VERSYM           0000000000400420  00000420
       0000000000000018  0000000000000002   A       4     0     2
  [ 7] .gnu.version_r    VERNEED          0000000000400438  00000438
       0000000000000030  0000000000000000   A       5     1     8
  [ 8] .rela.plt         RELA             0000000000400468  00000468
       0000000000000108  0000000000000018  AI       4    16     8
  [ 9] .plt              PROGBITS         0000000000400570  00000570
       00000000000000c0  0000000000000010  AX       0     0     16
  [10] .text             PROGBITS         0000000000400630  00000630
       0000000000010993  0000000000000000  AX       0     0     16
  [11] .rodata           PROGBITS         0000000000410fd0  00010fd0
       0000000000006688  0000000000000000   A       0     0     16
  [12] .eh_frame         X86_64_UNWIND    0000000000417658  00017658
       00000000000018f0  0000000000000000   A       0     0     8
  [13] .tdata            PROGBITS         0000000000619e08  00019e08
       00000000000000b8  0000000000000000 WAT       0     0     8
  [14] .tbss             NOBITS           0000000000619ec0  00019ec0
       0000000000000008  0000000000000000 WAT       0     0     8
  [15] .dynamic          DYNAMIC          0000000000619ec0  00019ec0
       0000000000000140  0000000000000010  WA       5     0     8
  [16] .got.plt          PROGBITS         000000000061a000  0001a000
       0000000000000070  0000000000000008  WA       0     0     8
  [17] .data             PROGBITS         000000000061a070  0001a070
       0000000000000048  0000000000000000  WA       0     0     8
  [18] .bss              NOBITS           000000000061a0b8  0001a0b8
       0000000000000048  0000000000000000  WA       0     0     8
  [19] .comment          PROGBITS         0000000000000000  0001a0b8
       0000000000000055  0000000000000001  MS       0     0     1
  [20] .shstrtab         STRTAB           0000000000000000  0001a10d
       00000000000000b1  0000000000000000           0     0     1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings), l (large)
  I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  PHDR           0x0000000000000040 0x0000000000400040 0x0000000000400040
                 0x00000000000001f8 0x00000000000001f8  R E    8
  INTERP         0x0000000000000238 0x0000000000400238 0x0000000000400238
                 0x000000000000000f 0x000000000000000f  R      1
      [Requesting program interpreter: /lib/ld64.so.1]
  LOAD           0x0000000000000000 0x0000000000400000 0x0000000000400000
                 0x0000000000018f48 0x0000000000018f48  R E    200000
  LOAD           0x0000000000019e08 0x0000000000619e08 0x0000000000619e08
                 0x00000000000002b0 0x00000000000002f8  RW     200000
  DYNAMIC        0x0000000000019ec0 0x0000000000619ec0 0x0000000000619ec0
                 0x0000000000000140 0x0000000000000140  RW     8
  NOTE           0x0000000000000248 0x0000000000400248 0x0000000000400248
                 0x0000000000000024 0x0000000000000024  R      4
  TLS            0x0000000000019e08 0x0000000000619e08 0x0000000000619e08
                 0x00000000000000b8 0x00000000000000c0  R      8
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RW     10
  GNU_RELRO      0x0000000000019e08 0x0000000000619e08 0x0000000000619e08
                 0x00000000000001f8 0x00000000000001f8  R      1

 Section to Segment mapping:
  Segment Sections...
   00     
   01     .interp 
   02     .interp .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.plt .plt .text .rodata .eh_frame 
   03     .tdata .dynamic .got.plt .data .bss 
   04     .dynamic 
   05     .note.gnu.build-id 
   06     .tdata .tbss 
   07     
   08     .tdata .dynamic 
[dahn@blimbing redox]$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/6.2.1/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --disable-libgcj --with-isl --enable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 6.2.1 20160916 (Red Hat 6.2.1-2) (GCC) 

It seems the same to me. What am I looking for?

So as a follow up for people hitting this as they search to solve their problems. I was a problem with the gcc.spec file on fedora as conmpared to for instance the one on ubuntu. The linker was creating linux dynamically linked binaries which is not helpful for running another oss’s init process. A patch was added to the redox toolchain so no one should encounter teh exact same problem anymore.