troglobit / finit

Fast init for Linux. Cookies included
https://troglobit.com/projects/finit/
MIT License
633 stars 63 forks source link

Failed connecting to shared memory, error 38: Function not implemented #81

Closed joerg-krause closed 7 years ago

joerg-krause commented 7 years ago

I am trying finit on a Banana Pro board using Buildroot (Linux 4.13.4). Using latest finit commit 9d9dc747681df865d13567c39d928aa819d72b9e. Running Linux system on a SD-card.

[    2.172219] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    2.180407] VFS: Mounted root (ext4 filesystem) readonly on device 179:2.
[    2.187794] devtmpfs: mounted
[    2.191904] Freeing unused kernel memory: 1024K
[    2.719908] EXT4-fs (mmcblk0p2): re-mounted. Opts: data=ordered
/usr/sbin/finit: Failed connecting to shared memory, error 38: Function not implemented
[    2.804870] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00007f00
[    2.804870] 
[    2.814011] CPU: 1 PID: 1 Comm: finit Not tainted 4.13.4 #2
[    2.819575] Hardware name: Allwinner sun7i (A20) Family
[    2.824829] [<c010e46c>] (unwind_backtrace) from [<c010b194>] (show_stack+0x10/0x14)
[    2.832571] [<c010b194>] (show_stack) from [<c0624994>] (dump_stack+0x84/0x98)
[    2.839793] [<c0624994>] (dump_stack) from [<c011b4e8>] (panic+0xdc/0x248)
[    2.846665] [<c011b4e8>] (panic) from [<c011e008>] (do_exit+0xa64/0xa94)
[    2.853363] [<c011e008>] (do_exit) from [<c011ee04>] (do_group_exit+0x3c/0xd0)
[    2.860579] [<c011ee04>] (do_group_exit) from [<c011eea8>] (__wake_up_parent+0x0/0x18)
[    2.868498] CPU0: stopping
[    2.871209] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.13.4 #2
[    2.877119] Hardware name: Allwinner sun7i (A20) Family
[    2.882347] [<c010e46c>] (unwind_backtrace) from [<c010b194>] (show_stack+0x10/0x14)
[    2.890087] [<c010b194>] (show_stack) from [<c0624994>] (dump_stack+0x84/0x98)
[    2.897304] [<c0624994>] (dump_stack) from [<c010d774>] (handle_IPI+0x170/0x190)
[    2.904693] [<c010d774>] (handle_IPI) from [<c01014dc>] (gic_handle_irq+0x8c/0x90)
[    2.912256] [<c01014dc>] (gic_handle_irq) from [<c010bccc>] (__irq_svc+0x6c/0x90)
[    2.919728] Exception stack(0xc0a01f48 to 0xc0a01f90)
[    2.924776] 1f40:                   00000000 00001364 2ee75000 c0116fc0 c0a00000 c0a03cb4
[    2.932945] 1f60: c0a03c68 c0a59592 c0a60700 c0937a28 ef7e1f40 00000000 2ee75000 c0a01f98
[    2.941110] 1f80: c0107f68 c0107f6c 60000013 ffffffff
[    2.946160] [<c010bccc>] (__irq_svc) from [<c0107f6c>] (arch_cpu_idle+0x38/0x3c)
[    2.953553] [<c0107f6c>] (arch_cpu_idle) from [<c014f6d8>] (do_idle+0xc0/0x138)
[    2.960858] [<c014f6d8>] (do_idle) from [<c014f9b8>] (cpu_startup_entry+0x18/0x1c)
[    2.968426] [<c014f9b8>] (cpu_startup_entry) from [<c0900c54>] (start_kernel+0x374/0x380)
[    2.976600] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x00007f00
[    2.976600]
troglobit commented 7 years ago

The kernel needs to be built with CONFIG_SYSVIPC to enable shm routines. Not sure about uclibc-ng, since I've never used it, but if that too can be configured it too needs to enable shmat() and shmget() functions: https://cgit.openadk.org/cgi/cgit/uclibc-ng.git/tree/libc/misc/sysvipc/shm.c

This is an old, somewhat undocumented, requirement that stems from initctl (and previous plugin implementation in Finit 1) having a way to connect to the internals of Finit svc.h. I should probably refactor this ...

troglobit commented 7 years ago

The reason you get a kernel panic, above, is that finit calls abort() if shmat() or shmget() fails.

troglobit commented 7 years ago

Trying to implement a workaround now, so at least finit (PID 1) can continue if this error is found at runtime. The initctl show and initctl cond show commands will however not work, that requires a more extensive refactor.

troglobit commented 7 years ago

I hope the fix I pushed in 3d4e3c9 is sufficient for now.

joerg-krause commented 7 years ago

Thanks! Enabling CONFIG_SYSVIPC in the Linux kernel fixes the issue. As the board is build using the default sunxi defconfig it is indeed a good idea to have that workaround.

joerg-krause commented 7 years ago

I can confirm that the workaround fixes the issue if the Linux kernel option CONFIG_SYSVIPC is not set.

/usr/sbin/finit: Kernel does support SYSV shmat() IPC, error 38: Function not implemented
/usr/sbin/finit: Implementing PID 1 workaround, initctl tool will not work ...: Function not implemented
finit[1]: conf_reload_dynamic():Skipping /etc/finit.d, no files found ...

Jan  1 00:00:11 finit[1]: conf_reload_dynamic():Skipping /etc/finit.d, no files found ...

finit[1]: sm_step():Stopping services services not allowed in new runlevel ...

Jan  1 00:00:11 finit[1]: sm_step():Stopping services services not allowed in new runlevel ...

/usr/sbin/finit: Kernel does support SYSV shmat() IPC, error 38: Function not implemented
/usr/sbin/finit: Implementing PID 1 workaround, initctl tool will not work ...: Function not implemented

Please press Enter to activate this console.
troglobit commented 7 years ago

Great, thanks for checking! Just pushed a follow-up to silence further error messages.