#bentobox
1 messages ยท Page 2 of 1
fixed the relocation issues (1 loc fix)
what if i implement evdev into the pl011 driver
(i'm using this mostly as a keyboard until i write an xhci stack)
its quite jank but its better than no input
actually i cant because i cant detect key releases ๐
ill have to let doom play itself
why does each CPU have a different time
because it was really really laggy
so they were missing interrupts or something?
nah it was my printf spinlock
ah
Non reentrant printf L
it is reentrant, i meant my flanterm spinlock lol
yeah flanterm isn't thread safe
although I added independent string drawing calls to mine that were
huh? the PS/2 self test failed and now i have no name
its been a long day
qemu -smp 256 i assume
Oh! Do you actually need to have 256 CPUs?
Okay, thanks
especially not if you're running using software
cause all the cores are simulated via threads on your hosts
so... it'll just run slow
Yep
how many actual real cpus do you have on the host?
8 cores 16 threads
pleanty to test it then
doing a lil thing
did you start working on a window manager?
Ye
wow
are you doing it in C, or C++?
or what else
and what IPC mechanism do you use
Looking from the code, I believe it's C
Unix domain sockets
I thought about using C++ for this, but I stuck to C
I would like to use C++, but I'd want to port the C++ STL which requires me to write at least a little bit of libc code
I know I have mlibc mostly ported but I'd want this part of the OS to run purely on my own code
(except specifically libstdc++?)
(idk)
you probably dont need that much of libc, unless you want threads and stuff which arent really part of libc but are an additional thing
you can probably get by with just string manipulation, memory, heap, etc until you start wanting to use stuff like std::chrono
ive been cooking
dang 10k loc
just did a full system upgrade and nasm won't compile my idt anymore wtf
Idt init... fail I guess
it seems like i was doing push dword instead of push qword, and before it didn't complain about this
i'm not sure why i was even pushing a dword instead of a qword, probably a remnant from the old 32-bit bentobox
we now have signals, and i fixed the tty deadlock and added more abstraction
so instead of having the tty write directly to the screen it now has a worker thread that does it
running from the ext2 filesystem
when the build system detects that you made an initrd (with the livecd make rule) it will make the default option of the limine config be the livecd option
having loglevels really helps keep the framebuffer console clean at boot (this is LOG_DEBUG instead of LOG_INFO)
i need to work on this again
neofetch can run without procfs if you really want a fetch and dont care about running software maintained by a ghost
i ported neofetch before the rewrite but its so slow
hmmm, i may need locks in my ext2 fs 
i think my ahci driver also needs synchronization
do u do CoW fork
not yet
yeah
cuz shell script
i mean, 8 seconds is not that bad for non-CoW fork
but i should probably fix my filesystem issues first (should be an ez fix)
That seems really bad unless you're running under an emulator and the app is using a LOT of RAM
Or it's forking very often I guess, but your statement made it sound like a single one takes 8s
i meant that neofetch takes 8 seconds to run, mb
under non-kvm it would take 24 seconds in the old kernel
i think synchronization in my ahci driver first would help
i'll do a simple spinlock for now
yup that works
i wonder how much ram the rewrite uses
its probably more because mlibc allocates a bunch of buffers at startup iirc and i dont have CoW
yeah, expected
i should probably write a slab allocator for better memory usage too, but i'm lazy
i could try to compile binutils and gcc, but isn't that a lot of work and requires recompiling gcc like 3 times?
my ryzen 7 5800x could probably compile gcc at decent speeds, but an overclocked threadripper hooked up to a BMW radiator would probably be better
finally got this working
oh wait the tty froze
oh because its probably pid 1 ๐
yeah killing pid 2 kills the serial tty LOL
oh I did 1 instead of %1 
ported fastfetch
What is the "C" locale?
Default
AFAIK that one just takes whatever random crap the devs wrote
i fixed this by marking pid 1 as used in sched_install and then freeing it before spawning init
hmm sometimes when i run fastfetch i have a deadlock where fastfetch won't get woken up
hmmmmm
i wonder what is causing this tho
i cant replicate the issue on nosmp
ugh i need to debug signals again
i fixed some small signal quirks and it seems to be working better now
and the junk uptime is /proc/uptime not existing

(i did touch /proc/uptime)
perfect
cooking something
i finally started working on this again after only 7 months https://github.com/9xbt/hashi
i'm planning to make this limine compliant
why not multiboot2 or my own protocol? cba to support other protocols in bentobox
so i thought bash was crashing somehow? but its actually my init ignoring who woke it up
wait no nvm, my waitpid is bugged
ok fixed
fixed a GPF when removing a socket while it was being used (i forgot to initialize two pointers)
since im too lazy to write my own GUI library, i might try to port nanox because im too lazy to port full xorg
maybe i'll port xorg later but not for the time being
can merge 
Ncurses has been ported
We may get vim today
But there is an issue called being in class
ooo
where did my permissions go ๐ญ
oh oops i was always overwriting them in file_open ๐
eyyy
@tacit mirage
ty
I am jealous
lol, you'll get it working soon enough i bet
Maybe
uhhh
i may have some issues
that's for future me to figure out :p
so this works? that's weird
oh maybe its because i don't have rename()
i'll implement it tomorrow because i have to sleep because school
Don't go to school, problem solved
exactly!
I wish
i think my ext2 impl is fucked
yup. my ext2 impl had some nasty bugs
they're all fixed now and i also implemented renaming
and vim works perfectly
i also fixed a LOT of other bugs, including memory leaks
i think i'll add some screenshots to my readme
https://github.com/9xbt/bentobox/ added screenshots to the readme
i completely forgot i had ported figlet because i forgot to add it to the readme ๐
for some reason scrolling in vim is really laggy, like it slowly gets laggier and lagger to the point where you have 800ms lag spikes
but it still scrolls at the same speed, but its displaying like 1fps
its still usable because the scrolling doesn't die, but its weird
ok so its vim's syntax highlighting causing massive lag
everything else is fine
oh wait why the fuck is it using regex engine #0
setting it to 1 fixed it ๐ญ
should i add mouse support to my tty 
- called bentobox - has fork -- why is this so satisfying? ๐
lol
i fixed the selection position being off when you clicked and i also fixed the random left over mouse cursors
damn, how does limine boot in less than half a second
because i run qemu with bios & kvm
reminds me of when I installed freebsd on my computer, I think it was the first OS I used that had a cursor in vga
great work tho
awesome progress
we now have ACPI reboot & shutdown thanks to lai (before everyone starts screaming at me, i chose lai so i didn't have to migrate my acpi stuff to uACPI)
How ๐ dare ๐ you ๐ซต not โ use ๐ป uacpi โจ for ๐งโ๐ป all ๐ your ๐ซต acpi ๐ค needs? ๐ฑ
not
enough ๐ฅ emojis ๐ฉ
Your ๐ซต OS ๐ป is ๐cool ๐
i've just realized that mouse support for vim also works in the serial tty, nice.
for some reason when i use the mouse in vim, either in the serial tty or the graphical tty, sometimes the whole scheduler will freeze and the cpu will be pegged at 100%
aha its a tty fifo deadlock
ahhh i think i know what's going on
my fifo has a spinlock and acquiring it from irq contexts is not good
should i just drop the character i'm trying to enqueue or make an irq safe acquire()?
i think i'll implement symlinks and then maybe setfont
i also need to implement readlink
symlinks are now fully implemented
for me, tuesdays and wednesdays especially (because the schedule is loaded with classes)
i finally have free time
i finally fixed an ext2 corruption bug i had for a long time
and added a few more assertions
this thing multitasks surprisingly well running with no smp under tcg
i can run two instances of doom at the same time and still use the system on the serial tty
sure its quite laggy but it seems like my new scheduler is quite stable
just fixed a polling issue that would make the tty hang sometimes
nothing changed?
oh wait no
it did
the fonts are just very similar
lol
ye
On an ssh connection from my phone :p
Using vim with a touch screen is funny
I'm not sure why it looks weird
Maybe termux doesn't support all ansi escape codes
It's probably the color scheme
This looks like something that would happen if you switched between dark and light theme
Ah
left telnet nyancat running while i was eating dinner, its quite stable
ugh i have some memory issues
[ 14.550321] kernel/misc/../../lib/dlmalloc.c:4751: free: aborted
[ 14.551048] Call Trace:
[ 14.551412] #0 0xffffffff800097ac in free+2092
[ 14.551969] #1 0xffffffff8000aac5 in kfree+37
[ 14.552524] #2 0xffffffff8000d1f1 in vma_destroy+369
[ 14.553107] #3 0xffffffff8000db99 in sched_cleaner+505
[ 14.558938] kernel/misc/../../lib/dlmalloc.c:4777: free: aborted
[ 14.559598] Call Trace:
[ 14.559934] #0 0xffffffff8000aac5 in kfree+37
[ 14.560459] #1 0xffffffff8000dbb3 in sched_cleaner+531
[ 14.561002] kernel/misc/../../lib/dlmalloc.c:4751: free: aborted
[ 14.561638] Call Trace:
[ 14.561971] #0 0xffffffff800097ac in free+2092
[ 14.562498] #1 0xffffffff8000aac5 in kfree+37
[ 14.562993] #2 0xffffffff8000dc03 in sched_cleaner+611
i have no idea what is causing this
maan i thought this didn't have memory issues ๐
so seems like if i dont spam vim a lot it works just fine?
what the fuck is this
the issue only happens when i run vim
maybe i could implement syscall tracing and check every syscall for memory issues
i thought i had found the bug, but i did not.
so my process struct is getting corrupted
ooo
[ 1.573833] x86 Fault: general protection fault on CPU 1
[ 1.575256] // Oops.
[ 1.576062] rdi: 0xffffc00000401f20 rsi: 0x0000000000000001 rbp: 0xffffc00000420c10
[ 1.577359] rsp: 0xffffc00000420be0 rbx: 0x000055555593fcc0 rdx: 0xffffffffffffffff
[ 1.578860] rcx: 0x0000000000000001 rax: 0xcccccccccccccccc rip: 0xffffffff8001b377
[ 1.580098] r8: 0x0000000000000001 r9: 0x0000000000000000 r10: 0x000000000000000a
[ 1.581289] r11: 0x0000000000000246 r12: 0x0000000000000000 r13: 0x0000000000000000
[ 1.582443] r14: 0x0000000000000000 r15: 0x0000000000000000 cr2: 0x0000000000000000
[ 1.583583] cs: 0x0000000000000008 ss: 0x0000000000000010 rflags: 0x0000000000010286
[ 1.584738] Call Trace:
[ 1.586355] #0 0xffffffff8001cb9e in isr_handler+1072
[ 1.587289] #1 0xffffffff80046819 in int_stub13+33
[ 1.588315] #2 0xffffffff80014114 in sys_read_write+261
[ 1.589514] #3 0xffffffff8001423c in sys_read+48
[ 1.590686] #4 0xffffffff80016efd in syscall_handler+195
[ 1.591958] #5 0xffffffff800202e5 in do_syscall+153
[ 1.592967] #6 0xffffffff8004b03a in syscall_entry+58
(i added heap poisoning)
fml
oh my fucking god
i found the issue
it was a one line fix.
this use-after-free would corrupt everything so badly
this also fixed a freezing bug in vim
oooh i may be able to get a proper keyboard working on arm with virtio
ok nvm im too tired to do this today
at least i fixed the arm build
arm is kinda unstable (i dont handle segfaults and user copy fails) and coreutils ls is weirdly bugged
ls -l will give the kernel a null path
and running bash nested will page fault
where are the colors
:(
at least we have nyancat
doom should work as well but my keyboard driver is the pl011 console rn ๐ so i cant really play it
my struct stat was wrong on arm
that is also why this crashed
ls -l seems to be crashing in FutexLockImpl<false>::lock()
it seems to be trying to lock a null futex?
for some reason the mlibc allocator has a corrupted slab pool
let me direct you to the good ol' reliable frg::slab_pool corruption bug diagnosis flow chart 
ah yes
implemented an mmio virtio-input driver
so apparently calling localtime is causing the corruption
Does your mlibc port run with map file windows?
what's that?
mmapping files instead of using read to read them
Theres a mlibc option that enables the memory mapping of internal files like /etc/localtime
oh its an option?
Yeah
MAP_FILE_WINDOWS
Or something like that
Ive written a line about all of these config options in the wip porting guide
Wait
Why /etc/localtime
What's special about that
Is it like a fake file that you read for the current time or?
where is that option
no its on your filesystem
xrc2 ๎ฐ ~ ๎ฑ src ๎ฑ bentobox ๎ฐ hexdump -C /etc/localtime ๎ฒ SIGINT ๎ฒ ST 12 ๎ณ ๎ rewrite
00000000 54 5a 69 66 32 00 00 00 00 00 00 00 00 00 00 00 |TZif2...........|
00000010 00 00 00 00 00 00 00 0b 00 00 00 0b 00 00 00 00 |................|
00000020 00 00 00 a2 00 00 00 0b 00 00 00 1b 80 00 00 00 |................|
00000030 9e ba c5 f0 9f a0 39 00 a0 90 1b f0 a1 81 6c 80 |......9.......l.|
00000040 aa 05 ef 70 aa e7 6e 00 ad c9 a7 f0 ae a7 32 00 |...p..n.......2.|
00000050 af a0 4f 70 b0 87 14 00 b1 89 7a 00 b2 70 30 80 |..Op......z..p0.|
00000060 b3 72 88 70 b4 50 12 80 c2 c9 ec f0 c3 58 5d 00 |.r.p.P.......X].|
00000070 c4 48 3f f0 c4 6d 1b e0 c5 39 74 60 c7 21 5b 80 |.H?..m...9t`.![.|
00000080 c7 f5 8e f0 cb f5 de 60 cc 95 71 f0 cd c3 4b 60 |.......`..q...K`|
00000090 ce a0 d5 70 cf a3 2d 60 d0 80 b7 70 d1 83 0f 60 |...p..-`...p...`|
000000a0 d2 60 99 70 d3 62 f1 60 d4 40 7b 70 d9 1e 46 e0 |.`.p.b.`.@{p..F.|
Every port seems to enable it in the root meson.build
oh, is it this?
elif host_machine.system() == 'astral'
rtld_include_dirs += include_directories('sysdeps/astral/include')
libc_include_dirs += include_directories('sysdeps/astral/include')
internal_conf.set10('MLIBC_MAP_DSO_SEGMENTS', true)
internal_conf.set10('MLIBC_MAP_FILE_WINDOWS', true)
internal_conf.set10('MLIBC_MMAP_ALLOCATE_DSO', true)
subdir('sysdeps/astral')
also no, i dont enable it
Yeah that
so uh its dying in parse_tzfile_path
i just did some refactoring of the ps2 driver and in total i've eaten away 150loc
mmm
just fixed a race condition in the scheduler that would make fastfetch never get cleaned when i ran qemu with tcg
much better
i realized i haven't tried tried running fastfetch on arm yet, but here it is
Why did discord compress my second fastfetch screenshot so much
there's quite a few things i want to implement but i have no idea where to start
Xorg would be really nice but i need to implement quite a bit of stuff before i can get it running at all
so i may look into porting gcc instead
after gcc i may look into CoW fork and maybe dynamic linking
or should i port llvm instead?
Doesn't GCC depend on dynamic linkage?
I don't think so
root@bentobox [ /tmp ]# mkdir foo
root@bentobox [ /tmp ]# ls
foo foo
root@bentobox [ /tmp ]# huh?
bash: huh?: command not found
root@bentobox [ /tmp ]# rmdir foo
root@bentobox [ /tmp ]# ls
'[pipe::read]'
root@bentobox [ /tmp ]#
๐
i think i got CoW working
but on tcg bash will sometimes die when i run something, and only sometimes
there is no error, just death
ok i think its my signals
yeah it was
made it work on aarch64 as well
real hardware
for some reason SMP will make it crash, and LAI tries to allocate something of 0 bytes and does a null deref (I should use uACPI), but disabling both of those things makes it work
even the trackpad works in vim
it forked 4740 times before freezing
and that's because i ctrl+c'd it
it froze at ~7500 forks
i somehow managed to decrease the ram usage
ok my cow fork broke some things
im not sure what i got wrong
oh i managed to fix it
lets go
errrrr
oh wait i forgot to mount /proc
i was only doing CoW if i was in ring 3, but i must do it in ring 0 as well
lmfao i was wondering why the /etc/rc script was running so slowly (fastfetch was fine), and i realized i was running this with tcg
fastfetch runs as fast as kvm before i implemented CoW
were you just cloning the whole process before?
and all the backing pages
yeah
im not sure if i wanna mount my filesystems with /etc/rc or just mount them in c
mounting them in c is way faster but less flexible
i forgot about this ๐
because it was compiling with _NSIG=1024
so i got mounting working today
along with umask and chmod
i also fixed a bug in vfs_rename
and separated the base folders for x86_64 and aarch64 so i don't have to rebuild everything every time i want to switch arches
i need to optimize my exec because its really slow
fork is pretty much instant but exec is sloow
ok that requires demand paging and i dont feel like implementing it today
or i could just get rid of /etc/rc and write it in c
I ended up doing this
i forgot i left this running in the background
Serial Id imagine
true, looking at the terminal title
I haven't worked on this for a few days
I wanna look into GCC and dynamic linking
Also, my exec is pretty slow rn because it loads the whole executable at once, how can I optimize this? With demand paging?
loading the whole executable at once shouldnt be slow
unless you have really slow file io
or normally the executable file would be mmapped
demand paging the executable
so you basically map all of its sections as CoW, apply your relocations if needed, then change the protections to their proper ones
It's only around 30ms on kvm but on TCG it's like 150ms and running scripts is really slow
why it looks like ssh
oh
why are you testing tcg at all
i always use kvm since tcg is unbearably slow for literally anything
while kvm runs perfectly fine
because i don't have an aarch64 computer
because its serial in alacritty
i wanna get a dumb terminal someday, they're sick
๐ญ
come on at least i have a proper serial tty that hooks up into my tty subsystem
oh
right i forgot people do inferior architectures 
aarch64 is fine, i could do just x86-64 but this forces me to make architecture specific code be abstracted
maybe there is a race condition between the thing that gives those CPUs idle threads and the CPUs themselves
which makes me say that you should probably have each core create their own idle thread
i split the loop into two and it fixed the assertion failing but it seems like there's cpus that aren't running for some reason
oh wtf why is this not working even with nosmp? it worked before
maybe CoW broke it?
i dont know, why do random cpus have no threads
oh wait, this isnt a joke? was waiting for the punchline
im curious that other cpus keep running though
isnt that a fatal condition
ah
holy shit cross compiling binutils does NOT have to be this hard
im getting tons of random fucking compilation errors
send them
hold on im troubleshooting
real hardware baby (on ttyS0)
fixed it, it was some fifo bs
i think everything works properly on real hw now
the PS2 driver works on my laptop and i can play doom and also use the mouse in vim
Lol nice
i have somehow managed to compile a bare gcc 16 in like 5 minutes on my ryzen 5 5600x ๐ญ
i mean gcc with only libgcc and libstdc++ and bootstrap disabled compiles really quickly
back when it was my main machine, i could build the managarm system-gcc in 15min on an i5-3210m
ah
bootstrap is probably the biggest time sink since it just triples the compile time
since it first builds gcc with the host compiler, then builds gcc with the previous gcc, then builds gcc with the previous gcc, and finally compares the last two to make sure they're the same
yeah
binutils for some reason has decided that bentobox uses PE
i've been fighting this shit for the past 3 hours
i dont think its that hard
my r5 5600h can compile bootstrap gcc in about 3 or 4 minutes
i was expecting it to take way longer
wtf
make sense though
so it turns out gcc wasn't finding cc1 because i was using ~ in my PATH instead of $HOME
i got distracted watching youtube, i'll finish patching it tomorrow
genext2fs just took like 5 minutes to make the hdd image for this thing btw
and my ext2 driver does not like mkfs.ext2 images for some reason
ok i forgot to strip cc1
it was 464mb ๐
and it was causing my kernel heap to run out of memory
ok i have some issues with gcc
fuck yeah
you forgot to clone submodules
and im still fixing the port scripts to use the new toolchain so you won't be able to compile ports rn
ok wtf
my bash build just broke completely
ok its because the git mirror i was using applied bash patches 4-8 which broke everything for me
what in the actual fuck is going on
ok so it does not like my gcc 16 toolchain
no way bro is using lai
true believer
i didn't feel like making all my acpi code use uacpi's stuff
lai was the most plug and play lib i could get
although it hasn't worked on any of the real hardware i own
i'll move to uacpi soonโข
that used to be a big problem for managarm iirc
On my laptop it tries to allocate 0 bytes and page faults
And on my Acer board it gets stuck in an infinite loop
uacpi also used to have a bug in some edge cases that would trigger 0 byte allocations
But I patched it and also added an assertion in tests to catch such cases
I caught it because I have an assertion in my malloc
why you use patches for bash
because bash ships patches instead of making a release with them included for some god damn stupid fucking reason
the guy that made this repo applied them 2 weeks ago https://github.com/bminor/bash
and i hadn't built bash in a while so it didn't affect me until i tried to rebuild it
also i think bash does not like being built with gcc 16, i get so many random errors
ok so zsh works but sometimes its crashing randomly for no reason
probably because of my fragile signal implementation
so i'll try to patch bash again
for some reason linking this is really slow, maybe its slow file io?
also i think my vfs has a use after free bug in unlink
oh wtf why is /tmp persisting after reboot...
that was a silly vfs bug
i still need to fix doing file ops on directories that have a mountpoint
but that's for later
also, removing files is a bit buggy and sometimes triggers use-after-free page faults
im not sure if this is my vfs' fault or my ext2 impl's fault
we'll see
absolutely, its way faster running with an initrd and compiling to /tmp
i'll have to optimize my ext2 driver more
(i dont have block cache and my writes do not check if it can do them sequentially)
also my tmpfs had a bug that caused corruption when i made gcc output binaries to it
but its fixed now
binutils is so i/o heavy
its screaming for me to optimize my ext2 driver but i cba rn
hmmm im not sure what to work on
i implemented pthreads
when xorg
welp, i've spent 6 hours building xorg just for it to not really work as it needs dynamic linking for drivers
btw do you have unix sockets
Yes
poll ?
yes
i haven't implemented it yet lol
isnt it already implemented by mlibc
the dynamic linker is
the kernel side isn't
but it shouldn't be too complicated
The kernel side is literally just loading a second ELF file and pushing context onto the stack
ok, i've tried to fix my toolchain for the past few hours to support dynamic linking, but it refuses to fucking work
what is error
also dont forget to win libtool demons if you want to have shared libraries
mlibc tires to probe for libgcc with a command that also links Scrt1
which i don't have because i don't have PIE
then try to have it
for example i dont support non pie executables
oh
so the fix was to make a symlink named Scrt1.o pointing to crt1.o
and when i installed mlibc it would install the proper Scrt1.o
rn i'm working on ET_DYN support in my elf loader
ugh i'm stuck here
wait i'm so fucking stupid
omfg my stack wasn't aligned ๐ญ
how did it take me SO LONG to find this
well i mean gdb wasn't cooperating AT ALL
welp adding another assertion to my scheduler
ok well dynamic linking works now
i managed to drastically reduce my sysroot's size
but but but but static linking the only good thing dynamic linking bad ๐ ๐ ๐
I find it so silly when people shill static linking like its the best thing in the world
lol
it wasn't even that complicated tbh i have no idea why i delayed it so much
except for finding the faulting instruction in this...
so my signal code broke out of nowhere yesterday
and wait i think i know why
or not
that's... an issue
fixed, i fucked up when updating my mlibc fork
so, i got Xorg running, but my VMA is page faulting. i think this is a design flaw of it, but shouldn't be too hard to fix.
nope
what is issue
two things:
- i can't move the mouse
- if i send a SIGINT, it will stop reading the mouse and will start reading the keyboard, and i don't think its my xf86-input drivers' fault
ig your poll or unix sockets have some issue
does it need to have a client connected for the mouse to work?
wdym
like rn i'm only running the x server and nothing else, there are no clients hooked up to it, but i think it should work as the cursor does render
yes you dont need any clients
what's your xf86 mouse driver
also i recommend to you to port xev
alr
maybe mlibc panics ?
maybe
i looked at your sysdeps and you dont print some message even on mlibc panic
but its opening my mouse device after it exits that thread
oh true
what is exit code
uhh not sure lemme print it rq
actually mlibc doesn't have exit codes for threads
but wait hold on
the hit io_seek() error 9 is from xkbcomp
why is it closing fd 0?
oh its xkbcomp
then all is fine if xorg can boot
then maybe issue in poll or unix sockets
like i had a lot of issues with them
hmm
Seems to be done by some applications before exiting, there is a pr open to make these errors ignored
ah
ugh i think my pthreads are broken
Ok so uh when I implemented dynamic linking I fucked up threading, but now it works again
But it's weird that xorg didn't crash because creating a thread would make mlibc segfault
a developer who solves their threads with problems has now problems more many

ugh i slacked off today
i haven't worked on it at all
but i'll probably work on it a good bit in a few days as i'm going on a road trip and i'll have nothing better to do
Me after slacking off for a literal month
lol
how do i compile bentobox
do i js
build the kernel and them build mlibc
because mlibc requires x86_64-pc-bentobox-gcc
i haven't updated the build instructions to include the toolchain
basically, first source build/mlibc-root, then run util/binutils.sh and then util/gcc.sh
if you see an ln error at the end of the gcc build ignore it
then you can build mlibc
and then the ports
and then the kernel
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-bentobox
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /usr/bin/sed
checking for gawk... gawk
checking for gdbserver support... no
checking for gcc... ccache gcc
checking whether the C compiler works... no
configure: error: in `/var/tmp/binutils':
configure: error: C compiler cannot create executables
See `config.log' for more details
same error in like
gcc
install ccache or modify the scripts to not use ccache
cd lib/mlibc && \
PATH="/home/cyntheria/bentobox/util/build/bin:$PATH" \
meson setup build-x86_64 --cross-file ../../build/crossfile-x86_64.txt -Dheaders_only=false \
-Ddefault_library=shared -Dbuild_tests=false -Dposix_option=enabled \
-Dlinux_option=disabled -Dglibc_option=enabled -Dbsd_option=enabled \
--prefix=/home/cyntheria/bentobox/build/base/x86_64/usr/
The Meson build system
Version: 1.10.0
Source dir: /home/cyntheria/bentobox/lib/mlibc
Build dir: /home/cyntheria/bentobox/lib/mlibc/build-x86_64
Build type: cross build
Project name: mlibc
Project version: undefined
Build machine cpu family: x86_64
Build machine cpu: x86_64
Host machine cpu family: x86_64
Host machine cpu: x86_64
Target machine cpu family: x86_64
Target machine cpu: x86_64
C compiler for the build machine: /usr/bin/ccache cc (gcc 15.2.1 "cc (GCC) 15.2.1 20251112")
C linker for the build machine: cc ld.bfd 2.45.1
C++ compiler for the build machine: /usr/bin/ccache c++ (gcc 15.2.1 "c++ (GCC) 15.2.1 20251112")
C++ linker for the build machine: c++ ld.bfd 2.45.1
meson.build:56:1: ERROR: Unknown compiler(s): [['x86_64-pc-bentobox-gcc']]
The following exception(s) were encountered:
Running `x86_64-pc-bentobox-gcc --version` gave "[Errno 2] No such file or directory: 'x86_64-pc-bentobox-gcc'"
A full log can be found at /home/cyntheria/bentobox/lib/mlibc/build-x86_64/meson-logs/meson-log.txt
make: *** [build/mlibc.mk:6: setup] Error 1
what the sigma
i ran the mlibc-root command too and then compiled binutils and gcc
wait
...
my binary that it compiled is "x86_64-bentobox-gcc"
this mesonbuild script assumes "x86_64-pc-bentobox-gcc"
no you don't have the compiler added to your path
add the full path of util/build/bin to your path
adding it to .bashrc works for me
i dont believe you
and where is that binary?
wrong emoji fuck
build/ is where i put a bunch of random helper scripts and where the limine stuff gets downloaded to
util/ exists because build/ was getting too messy
anyways
so i got xev running after implementing getsockopt and fixing a bug i had in socket_bind, but it isn't rendering in Xorg
i'm not sure why
yo btw can i like port wayland too
uhhh why when not even Xorg works fully yet
if xorg is done and works fully i meant
well then there's not really a point
uhhh well ig you can fork it if you want, and if it's convincing enough i'll merge it, but i don't really accept contributions rn as its more of a personal project
i'm fine i can manage it myself
i finally pushed a bunch of xorg work
it has been a productive day and I finally pushed after a week
so xorg-server runs and I can move the mouse which required a lot of random small bug fixes everywhere
but thank god I managed to debug this with gdb as debugging shared libraries inside qemu is a bit of a pain
anyways, what's left to debug is clients not rendering in Xorg (not sure if it's because it's trying to use shared memory but I don't think it is, or my sockets being buggy which is more probably) and the deadlock in xkbcomp when running under KVM
god it felt good pushing all of that work, I hadn't pushed in 6 days
when I get xorg working I may start working on the aarch64 side as it's a bit abandoned
but that's for later
hopefully I can get this working this year
Welp, I went on a trip so I may not be able to work on this as much as I do at home
But at least I got arch Linux set up nicely on my laptop
alright, since i don't feel like building xorg rn i may make the new toolchain work on aarch64 so i can get that working again
and holy shit discord is running at 5fps compiling vim
welp, I ran out of time to work on this this year
Heh. Hehehe.
wow i've just saved myself from hours of debugging. X would trigger a trap in abort() in mlibc, and i had no idea why, so i thought of rebuilding libgcc after building mlibc (even though i thought since i build a shared libc i wouldn't need to rebuild it) and it worked straight away.
and the deadlock is actually a coprocessor fault on my intel laptop
which i fixed by initializing the fpu state properly when i create the tcb context
debugging this on my intel laptop actually made it easier to catch ๐ญ
Sounds like an abi break
don't think so. when i built libgcc the first time i had to make a libc.so stub as it was trying to link against it when i didn't have mlibc built yet (which requires libgcc). ld didn't care about the fact that it was an empty file
but when i rebuilt it, i had mlibc already built properly and all, so maybe that magically fixed it
either way, it works now so i'm happy :^)
welp.
I can see it became a tradition to have your first test wm twm :P
:P
uh oh
seems to work fine on an initrd system so its 100% my ext2 driver causing the page fault
ahhhh silly mistake in vfs_link, i wasn't checking if old_node->ops->link was valid ๐
works now
apparently doomgeneric's xlib code is so bad that it will not check if the display opened successfully and will proceed to segfault if you don't have an x server open ๐ญ
damn it freezes on the doom screen
i have cleaned up my laptop as i didn't really feel any airflow coming out of it and the temps were quite high. turns out when i asked my dad to clean it a while ago he didn't take out the fan and clean the heatsink fins and there was a huge dust carpet.
now i can build gcc at 48C with the fans at full speed
the aarch64 toolchain has been fixed and i'm surprised i've only done 1 abi break in my kernel since i last compiled it on arm
i may try to run Xorg on it but for that i need to complete the arch-specific signal code (i couldn't be bothered to write it when i implemented signals)
man i forgot how spaghetti 90% of my aarch64 code is
i really need to comment this shit ๐
mmm
bro i closed qemu and my cpu temp dropped a whole 25C ๐
i cannot put into words how much i despise arm
so uhhh i want to get Xorg working on arm, but rn signals are too unstable on it
i also want to get pci(e) working on it too but i kinda wanna fix signals
oh i also want to write pty stuff
so uhhhh
i completely threw out my current code, rewrote it, and now it worked first try ๐ญ๐ญ
and the code is way cleaner too
got pci working on arm
we now have kmsg
hell yeah (ext2 root on arm)
fixed some socket polling bugs, now when i launch something like xeyes it will spawn immediately instead of waiting for me to move my mouse
dang, the kernel is already ~12k loc and including the build scripts and everything its ~15k loc
should i add xsave support to this?
yes
so doom does try to run, but it freezes here (doom, not the vm)
i think it's just running absurdly slowly, maybe due to the lack of shared memory
I dont think that would be the problem
Well it takes a while to draw the main screen so idk
Maybe it's the freebsd doom code that needs some fixing
I do need to fix a deadlock that happens when the system is under heavy load and I move the mouse (it gets stuck in a spinlock in an IRQ handler)
also xclock ticking may be some setitimer stubs I have in mlibc that I forgot about doing nothing
i didn't implement itimers yet, but xclock does tick
Oh, then I'm not sure
did you fixed this
very stupid question but did you run xclock -update 1?
Yeah
No I'm on a highway
while working on something completely unrelated i found the issue. my sys_gettime syscall doesn't set tv_nsec when the clock is CLOCK_REALTIME, which is what doomgeneric's xlib code uses (it uses gettimeofday), and the reason my doomgeneric code worked is because i manually call clock_gettime with CLOCK_MONOTONIC
i don't even zero tv_nsec so it's clearly an oversight
finally dude
i had to create a stupid script to fix the x keymap after launching xorg
its being gay
it's a bit laggy but do take in mind its a RR with no priorities on only 2 cores
which nes emulator is this?
the one nanoshell uses
nes_emu
i don't have sdl2 so i told a clanker to port it to xlib and it actually worked
well, i kinda abandoned that one since it only supported a total of one (1) mapper
you should port the other emulator i ported to nanoshell
this one? https://github.com/ObaraEmmanuel/NES
yeah
huh, i may have an issue
sometimes it will just freeze but i realized that if i let it for a while it will eventually run out of memory
holy shit its using so much cpu for tlb shootdowns ๐ญ๐ญ
what is tlb shootdown
tlb invalidations
more specifically, making sure that the tlb entries for a given address are consistent across all processors
nooo my mario
i've NO idea why it did that
and the fact that rsp is a user address
why is it still playing ๐ญ๐ญ
Doom Eternal
Sending a page invalidation to all CPUs. You can do this using an ipi, but a lot of people create a queue of pages to be invalidated and invalidate them on their own time
i use an ipi, which is better?
the latter would be pretty bad bc the pages arent truly inaccessible for everyone
Oh I thought you could update some pet cpu state to tell the cpu to not use that page
Until it gets invalidated
As long as there is a valid entry in the TLB for an address, the data mapped at that address is accessible
If the target CPU gets a page fault then you can just read the PTE and see that it's invalid
Ah, I see
I personally like the name of this project so like im gonna star it
implemented load balancing in my scheduler, super mario bros runs soo much better than before with 2 cores
this too ๐ญ๐ญ
real productivity
tbh my kernel isn't that smp safe, there are a lot of places that don't have any synchronization mechanisms
so its pretty good for what it is
aight well, here's a list of things i may want to do, some in a long time:
- pci virtio drivers (so i can use them on x86 as well)
- a network stack (probably gonna use virtio)
- port htop (should be fairly easy, just need to implement a proper procfs)
- shared memory
- move to uacpi
- tsc & kvm clock
i may also want to make smp safer, as sometimes it crashes randomly and performance could be better
You don't even need a procfs
how would that work without one then?
You use other methods of getting the necessary info
Sometimes that's syscalls, other times it's /sys
OpenBSD has no concept of a procfs
Htop works just fine though :)
ah i see, tho i'll probably implement a proper procfs anyways because i already have /proc/meminfo and some other stuff
and it would make it easier to get stuff that already works with procfs working
True, but most of that already works on BSD or will need to be written in a kernel specific way anyways
But yeah every officially supported platform of htop has a subdirectory in the root of the source tree that houses platform specific code
ahh i see
for some fucking reason when i close xeyes in dwm xorg will still try sending shit to it resulting in a freeze when it reaches the packet cap
it ONLY does that with xeyes SPECIFICALLY, other shit works fine
and on linux it all works just fine
x has some kind of mask for events a process wants to receive. maybe that's not getting cleared, somehow?
it seems like when i close xeyes its not closing cleanly as its my cleaner process that is closing the socket
at least i think that's what's happening
yeah, and i'm thinking it's only xeyes because of that mask; xeyes needs the mouse position all the time.
i mean, other processses sockets might not be closing cleanly either, but no more data is sent to them.
hmmm
but x keeps sending that data even after i closed it, even a whole second later when it freezes because its hitting my cap
yeah, but what i mean is xeyes could be the only one which x has more data to send to because it's still registered for mouse movement via the event mask.
maybe
isnt exec is forbidden inside pthreads
no idea
recompiling it fixed it
๐
I don't see why it would be, c++ std::thread uses phreads under the hood on Linux and it doesn't set restrictions on where you can fork or exec or do other process related stuff
imagine if you had to send messages somehow back to a main thread to fork 
i slack off way too much ๐ญ
trust me u dont
true true
nes_emu
its not a great emulator but it's extremely easy to port
i vibe coded an xlib port that you can find here: https://github.com/9xbt/nes
why didnt you port the other emulator i ported
ty
ill port it
wow amazing context 
because i was lazy and i already ported this one before you told me to port the other one
i'll port it when i stop being lazy
so the nes emulator has been making my xorg freeze from time to time (it also happens sometimes with doom but far less) and it seems like x just stops receiving frames or goes to sleep or something happens that makes it freeze until i send a signal to it
i managed to make it freeze less often by doing some shit differently but it still freezes sometimes
thing is that it doesn't freeze at all with nosmp
so it has to be some race condition but i literally have no fucking clue what it could be
also bentobox is now a year and 6 days old
my is year and 4 days old
oh that's really close
i don't understand the freezing tho, xorg will just randomly block and go to sleep forever until i wake it up and it's only sometimes
how it sleeps
futex or poll
syscall log to debug
true
did you implement poll timeout
did timeout you implement poll
then try do run qemu without smp and disable pmm free
send ps2 mouse code
I have an idea
i said it doesn't freeze without smp
oops wrong person
no shit
true
hmm actually yk what maybe that's fixed
because now it seems like the nes emulator freezes, presumably in a spinlock
wtf
i forgot to mention that sometimes i will get these random crashes
what the hell
sometimes osdev is just rng
id like read over context switching like 5 times
hmmm
wait why tf is it using a user stack in kernel mode
inb4 its some sort of weird thing with gs base that happens in like 1 out of 10000 cases
it happened again, this time after the nes emulator froze and i tried to move it
i disabled pmm free and commented out my kfree poisoning code and it lasted way longer but in the end it still froze
hmmmmm
come on i got so far
it seems to last way longer by just disabling my heap poisoning code
but the emulator will still freeze after a while of playing and then xorg will go with it after a few seconds
the most osdev pain is debugging race conditions
oh absolutely
i ported uacpi today
wait didnt u have lai
yup, I got rid of it
how was the transition
well there was more glue code than i expected, but it wasn't that bad after all
not ready reading drive A ๐ญ
so uh i started implementing ptys today, but i cant stop slacking off
smh u r only doing it because I did it ur copying me smhsmh
nah i actually wanted to do this for a while lol
i ported st so technically i'm not copying you :P
I found ptys really easy just do it
yeah but i keep watching youtube on my second screen lol
lol
you copied me cuz i use st
crap
ok ill lock in
rn doing a bit of refactoring of my current tty code
oh my fucking god shut up
no way i cant fucking close this
dude
lmao i just got that too
doing ptys concurrently with STREAMS made it more pleasant for me
had to get rid of it with devtools
waaaait a minute
oh come on my theme hid the x button
i'm so fucking lazy
but i'll have tons of free time in a few days so i'll be forced to stop being lazy otherwise i'll be bored
so i've been slacking off for the past few days, but i noticed that a lot of my issues when starting up xorg are actually related to my ahci driver?
a lot of times my startwm script will clear the screen fine but when starting xorg it will just kill itself and leave the ahci driver in a state that will deadlock if i try to read/write anything
for some reason the pty won't wake up st to wake up xorg
added a twmrc
much better
ok so i somehow accidentally fixed it while doing some tty refactoring
but yeah this is way more stable with nosmp
is it using openrc or it just looks like it
You realize that openrc doesn't affect how things look right?
Or is there something I'm missing that makes you think it's openrc
yea i know
thats why i said or it just looks like it
Then how would it look like it uses openrc if openrc doesn't affect how things look
im saying the output looks like openrc
Which part?
that's a really really old screenshot and while i did port openrc before the 3rd rewrite no it is not
i moved to this style of logging
so i though i fixed the freezing in xorg, but on my faster machine it still seems to freeze a lot
ok so uh my sys_pselect impl in mlibc was broken and vfs_poll_multiplexed was also broken
its ALWAYS polling istfg
nyanyanyanyanya
it took him 6 years
i've been working on this os for a year
this kernel for the past 5 months
multitasking
Bentobox lowkey inspires me to come back to osdev again and work on something
thank you
fixed grep not outputting anything on ptys (it will refuse to do so if the pty inode is 0)
i had already fixed this issue on ttys but forgot to do so for ptys
dang the kernel rn is 13035loc
laughs in 13kloc and no framebuffer support yet
so today i fixed some stability issues that i had already fixed but accidentally broke
and i also made it so st and some other programs close properly
the issues left rn are minimizing in fvwm deadlocking xorg and starting up fvwm when running the kernel with smp takes way too long
try to do a lot of things lockleas
lockless*
it gave to me some performance
well i'm actually adding locks because otherwise its more unstable
this may be some wakeup issue actually because moving the mouse makes it start up faster
oh yeah i don't know why this happens sometimes, its random
what is these random messages ๐
// but it works on my machine
in kernel panic
so this
sorta
(its available in aur btw)
Lol I need to get it when I get outta bed
I need to implement pty cleanup
I get ./util/binutils.sh: line 10: /home/connor/bentobox/util/binutils-gdb/configure: No such file or directory
is binutils downloaded successfuly
you probably forgot to initialize submodules
git submodule update --init, it'll take a while
so fvwm deadlocking xorg was uninitialized memory in sys_msg_recv and sys_msg_send in my mlibc sysdeps...
adding hdr->msg_controllen = 0; fixed it and i won't bother implementing fd passing yet
although i really need to move these sysdeps to my kernel
minimizing in fvwm also works now
actually not setting controllen to any value is bug
i had this issue too
ah
because msg just didnt get zeroed before use
yeah
ok time to slop slacking off and implement the syscalls (i was watching a video)
so I just implemented the syscall, works great, now the only issues left are dwm freezing xorg when closing windows because it probably just kills them instead of asking nicely for them to kill themselves, and fvwm taking longer than usual to start up with smp
now i get
connor@unknownb29e6058d884:~/bentobox$ ./util/binutils.sh
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-bentobox
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /usr/bin/sed
checking for gawk... gawk
checking for gdbserver support... no
checking for gcc... ccache gcc
checking whether the C compiler works... no
configure: error: in `/var/tmp/binutils-x86_64':
configure: error: C compiler cannot create executables
See `config.log' for more details
connor@unknownb29e6058d884:~/bentobox$
install ccache
i always forget to add it to the readme
you could also probably just export CC to gcc
nice mac address
lol
thanks 
No work has been done today because I've been watching anime since I got home
thanks
i like fvwm so much more than twm ๐ญ
i was working on pty cleanup today when i started getting gpfs everytime i closed st
well it turns out that even after undoing all of my changes it still gpfs ๐ญ
i think the issue is that there's some double free or use after free somewhere
but god is this annoying me
I forgot to mention that there will be no work on this until this Saturday since I'm going on a trip
Bro someone put their head through my hotel rooms door and fucking broken a rectangular section of it ๐
when they said use your head I don't think this is what they meant
Lol it seems like they kicked it and since it's made of paper it immediately broke
hey yall, it's been a while. i'm finally home debugging my favorite thing again: race conditions
so, i've ended up stashing the pty cleanup code to focus on these use after free issues, it seems like i have a race condition in my scheduler with thread cleanup
as if i comment out this one line here:
static void sched_cleanup_thread(struct thread *tcb) {
if (tcb->cpu && tcb->cpu->current_tcb->value == tcb) {
tcb->state = THREAD_ZOMBIE;
arch_yield(tcb->cpu);
while (__atomic_load_n(&tcb->state, __ATOMIC_ACQUIRE) != THREAD_ZOMBIE_ACK) {
#ifdef __x86_64__
__builtin_ia32_pause();
#endif
}
}
arch_context_free(tcb);
sched_free_tid(tcb->tid);
if (tcb->cpu)
list_remove_value(tcb->cpu->threads, tcb);
// kfree(tcb);
__atomic_sub_fetch(&zombies_pending, 1, __ATOMIC_SEQ_CST);
}
it won't crash anymore
i think this issue may be specific to multithreaded programs
or just st triggering a specific race condition
but now that i'm looking at this, i think i'll have to do a bit of a redesign of my thread cleanup
well even after redesigning my whole fucking thread cleanup code i still have the same exact issue
wtf
race conditions is the most annoying to fix
are you executing thread cleanup code in the context of a reaper
ie not in the context of the thread being cleaned up
yeah
man i love this fucking kernel
oh i just realized i only give this 16kb of kernel stack, maybe i should give it more lol
but i'm not sure if that's the issue
yeah it wasn't lol it was my reaper being fucked
i still increased the stack size to 64kb tho
hmmm i'm at a decent state but i'm starting to get into mentality of a rewrite yet again
That is a huge kernel stack either way
16kb is a lot
The biggest kernels managed to get away with less than that for decades
ah, i thought it was a bit small since limine's default is 64kb and some rust kernels have over a megabyte of stack, but i guess it's rust being rust.