NSG650 / Polaris

A WIP 64-bit UNIX-like kernel
Apache License 2.0
311 stars 15 forks source link

Kernel panic: "tinyubsan: use of NULL pointer" #23

Closed matteodev8 closed 4 months ago

matteodev8 commented 5 months ago

Describe the bug After compiling the latest commit, I am getting this kernel panic in the serial monitor:

[10352] VFS: Mounted devtmpfs on '/dev'
[10896] Hello I am kernel_tasks running on CPU0
[11168] Ramdisk located at 0xffff8000069a9000
[74439] tinyubsan: use of NULL pointer at file ../../fs/vfs.c, line 434, column 2
[74582] AH! UNHANDLED EXCEPTION!
[74624] RIP: 0xffffffff800b7af6 RBP: 0xffff80000061cf38 RSP: 0xffff80000061cec0
[74677] RAX: (nil) RBX: 0xffff800000f9c6c8 RCX: 0x0000000000000008
[74738] RDX: 0x0000000000000008 RDI: (nil) RSI: 0xffff80000054c1d0
[74769] R8 : (nil) R9 : 0xffffffff80046504 R10: 0x000000000000000a
[74796] R11: 0x0000000000004000 R12: 0xffff800006830900 R13: 0x0000000000000008
[74860] R14: 0xffff80000054c1d0 R15: 0xffff80000067fd00 ERR: 0b10
[77180] CS : 0x0000000000000008 SS : 0x0000000000000010 RFLAGS: 0x0000000000000282
[77249] FS: (nil) UGS: 0xffff800000553200 KGS: 0xffff800000553200
*** PANIC:      Panic called on CPU0
*** PANIC:      Current thread id: 0
*** PANIC:      Process name corresponding to the current thread: kernel_tasks
*** PANIC:      Page fault at (nil) present: NP, read/write: R, user/supervisor: S, reserved: NR, execute: NX
*** PANIC:      Crashed at 0xffffffff800b7af6
*** PANIC:      Stack trace:
*** PANIC:      Kernel base: 0xffffffff80000000 Mem phys base: 0xffff800000000000
*** PANIC:      Loaded drivers

To Reproduce Steps to reproduce the behavior:

  1. Use qemu-system-x86_64 -M q35 -m 512M -cdrom polaris.iso -serial stdio -boot d QEMU parameters
  2. Either select KASLR on or off
  3. See error

Expected behavior Successful boot

Screenshots image

Environment (please complete the following information):

Additional context X

NSG650 commented 5 months ago

Change the memory size to something >= 1.5GB and try booting. We have to update the instructions for running.

NSG650 commented 5 months ago

Also heads up you will have to patch the libc as well for adding the ppoll syscall and fixing a few other syscalls made. So any bugs relating to being able to chdir into an non existent directory or bash simply exitting is known.

matteodev8 commented 5 months ago

Increasing the RAM did fix it, and yes, bash is exiting

bash: cannot set terminal process group (-1): Bad file descriptor (EBADF)

I'll tinker around with it

matteodev8 commented 4 months ago

Gonna close this now since the issues are now gone in the later commits