#OBOS (not vibecoded)
1 messages · Page 32 of 1
qookie@selenium ~/projects/mlibc/src λ find -name ioctl.h
./sysdeps/vinix/include/asm/ioctl.h
./sysdeps/lyre/include/asm/ioctl.h
./options/glibc/include/sys/ioctl.h
``` seems like a bug?
can you check git blame for that line 
e773a516a options/posix/generic/posix_stdlib.cpp (Geert Custers 2020-08-28 11:36:53 +0200 17) #include <mlibc/posix-sysdeps.hpp>```
it's been there for ages
who is Geert Custers
and astral doesn't seem to have that header either
Think hard
that's not the line
shit I can't read
0a20b6aef options/posix/generic/posix_stdlib.cpp (Alexander van der Grinten 2019-07-20 19:12:22 +0200 11) #include <sys/ioctl.h>
isn't that portmaster
no
that's because mathewnd enables glibc, which I assume also imports that header
Close enough
korona?
no
we dont know who that guy is
he's a random contributor
his name was only heard of in legends
Yes
re. geert, i want you to start typing in @ geert without the space (maybe not in here but in a normal channel)
I'm sorry I'm not up to date with all the managarm lore
boring
Sorry 
||I found that out through discord search||
anyway you could yoink the lyre or vinix sys/ioctl.h
afaics it's the linux one?
ah no nvm
i misread the paths
just enable the glibc option for now 
yeah that should be fixed, for now you can just add a #define _GNU_SOURCE on top of that file I think
hmm
well it solves it there, but other errors pop up elsewhere
maybe I should just yoink sys/ioctl.h
i think _GNU_SOURCE should be getting defined by the compiler?
maybe I don't enable it in my GCC patch
its not because mlibc does cpp_std=c++20 instead of cpp_std=gnu++20
I think it would make sense to change that like its already changed to gnu for c
I did this, to be greeted by
Obos is a bsd confirmed
lol
Obosd
obsd
I commented that out
and it turns out I can't just yoink that header
and I need the glibc option
it compiles now
astral also uses that patch, maybe it depends on some gcc config
possibly
we should probably build more combinations of options on ci
like ansi+posix without glibc,bsd,etc
yeah mlibc is kinda iffy when missing a few options
after all that, bash still doesn't build
with the same errors
about dprintf
interesting
it doesn't think mlibc has dprintf
wth
@weary hound I don't believe this should be happening?
bash soon??
yes
bash coming to an obos near you soon™️
/home/oberrow/x86_64-obos-bootstrap/bin/../lib/gcc/x86_64-obos/14.2.0/../../../../x86_64-obos/bin/ld: ./lib/termcap/libtermcap.a(termcap.o):/home/oberrow/Code/bash-5.2.37/lib/termcap/termcap.c:298: multiple definition of `PC'; ./lib/readline/libreadline.a(terminal.o):/home/oberrow/Code/bash-5.2.37/lib/readline/terminal.c:109: first defined here
/home/oberrow/x86_64-obos-bootstrap/bin/../lib/gcc/x86_64-obos/14.2.0/../../../../x86_64-obos/bin/ld: ./lib/termcap/libtermcap.a(tparam.o):/home/oberrow/Code/bash-5.2.37/lib/termcap/tparam.c:127: multiple definition of `BC'; ./lib/readline/libreadline.a(terminal.o):/home/oberrow/Code/bash-5.2.37/lib/readline/terminal.c:109: first defined here
/home/oberrow/x86_64-obos-bootstrap/bin/../lib/gcc/x86_64-obos/14.2.0/../../../../x86_64-obos/bin/ld: ./lib/termcap/libtermcap.a(tparam.o):/home/oberrow/Code/bash-5.2.37/lib/termcap/tparam.c:128: multiple definition of `UP'; ./lib/readline/libreadline.a(terminal.o):/home/oberrow/Code/bash-5.2.37/lib/readline/terminal.c:109: first defined here
/home/oberrow/x86_64-obos-bootstrap/bin/../lib/gcc/x86_64-obos/14.2.0/../../../../x86_64-obos/bin/ld: warning: /home/oberrow/x86_64-obos-bootstrap/bin/../lib/gcc/x86_64-obos/14.2.0/crtend.o: missing .note.GNU-stack section implies executable stack
nearly there...
through some funny buisness I got those to go away
[ LIBC ] Could not satisfy dependency libdl.so
[ LIBC ] mlibc panicked! exiting program....so
in mlibc?
if its in /usr/lib in the sysroot then your open or stat syscall is bad, sorry
what stat syscall 
\s/stat/whatever your stat syscall is
get a syscall log and see what happends
xd
thank god it wasn't a bug with open
the actual implementation
otherwise I would've found the nearest cliff and throw my computer off it
"fixed" that
(I SEGV now)
user mode read on a non-present page
0x412f5e50
at 0x41241620
judging by this, the page is probably swapped out, but I have a bug in that code
it could also be a bug in my lazy mapping code
[ DEBUG ] Handling page fault at 0x412f5000...
[ DEBUG ] Trying a swap in...
[ LOG ] User thread 6 SIGSEGV```
after enabling debug logs that's the last thing I see
which means the page does indeed have a page_range associated with it (i.e., it was mapped through sys_mmap)
but the kernel failed to handle the page fault for unknown reasons
fixed it
I think
- if (rng->cow && (ec & PF_EC_RW))
+ if (rng->cow)
{
+ if (rng->un.cow_type == COW_SYMMETRIC && (~ec & PF_EC_RW))
+ goto not_cow;```
[ LIBC ] In function ttyname, file ../options/posix/generic/unistd.cpp:829
__ensure(Library function fails due to missing sysdep) failed
[ LIBC ] In function getuid, file ../options/posix/generic/unistd.cpp:1118
__ensure(Library function fails due to missing sysdep) failed
[ LIBC ] In function getuid, file ../options/posix/generic/unistd.cpp:1119
__ensure(!"Cannot continue without sys_getuid()") failed
[ LIBC ] mlibc panicked! exiting program...```
Haha pp
hahahhaha
look under there
under where?
HAHAHA made you say underwear
what's the difference between sys_getpid and sys_getpgid
Pgid is program group id which is job control stuff
thanks
Or getpid
I am able to get it to run a bit further
a bunch of unimplemented signal sysdep messages
until it ultimately page faults and the kernel panics
in Vfs_FdWrite
it page faults
Something was here I accidentally edited the message
no prompt yet
BUT I at least get to the part where it writes to the "TTY"
@vale nymph do you know why this could be happening?
well first I guess I need sys_getcwd
this is weird
even though I have sys_getcwd
bash complains about it
"ENOSYS"
bash source code is brainrotten
but I would expect it to print on the libc log that it couldn't find the sysdep
and not on the TTY
hmm
bash's configure says GETCWD_BROKEN=1
which is odd
x86_64-obos-gcc -shared -L./lib/termcap -o print print.o
/home/oberrow/x86_64-obos-bootstrap/bin/../lib/gcc/x86_64-obos/14.2.0/../../../../x86_64-obos/bin/ld: /home/oberrow/x86_64-obos-bootstrap/bin/../lib/gcc/x86_64-obos/14.2.0/crtbegin.o: relocation R_X86_64_32 against hidden symbol `__TMC_END__' can not be used when making a shared object```
I decided to make install
bash
only to get this
well it's getting late now
so I'm off to sleep
you still have 1 more day left in the year
yeah, I've only got 9 and a half hours left in the year
this ain't fun
of porting
I thought you had gone to bed
how about u deal with scheduler UB 
I have, don't worry
even worse
like bro i just added thread states like running, ready, and zombie
crazy
a day or two I had to debug the scheduler
what was ze issue for u
specifically the context switching
idr, but it wasn't fun
that is always annoying
luckily for me it only happened in the first few context switches of the user program
and iirc it had something to do with stack switching
I think that's because I'm still using the "bootstrap gcc"
aka gcc built with inhibitLibc=true
anyway gn
nightnight
it's not needed
I don't have it
And bash works fine
Hm
Then why does it complain here
Because you fucked up
Makes perfect sense
I just love my isatty implementation
🤫
@vale nymph help
pls
I decided to remove my "isatty" implementation
and stub it out
but now bash just exits without doing any prompt
y stub it out
well this is how it's implemented
so I figured I should just stub it instead
implement it properly lol
you need pselect at the very least stubbed out to return success and 1 as the result (I just figured that out having that same issue on my kernel)
see lib/readline/input.c:833
I'll try that
ofc making it return 1 as the result and always succeeding isn't likely going to make it work very well but it shouldn't exit at least
I did that, still no prompt :(
did you also restore your original isatty stub
no
try that
not really needed for bash
@flint idol get a syscall log
something somewehre is failing
did you compile it for readline?
I just compiled it the same way you compile it
./configure --host=x86_64-obos --prefix=$HOME/Code/obos/tar/ --without-bash-malloc```
then make all
and then I copy bash to my initrd
and run that
sure
this will take a bit, as I need to implement syscall logging
hmmm probably it is using readline
for readline you need poll
if poll fails it exits
does mlibc complain about an unimplemented poll?
I was able to get it to stop exiting
I didn't get any polls either
that's all the unimplemented sysdep things I got
something is erroring out which bash doesnt like lol
btw now it hangs after printing some errors on stdout
there's my syscall log
except it has no syscall names
most the time, if a syscall returns zero that means success
but syscall 22 is mmap
which returns a void*
and 42 is TellOff
syscall 57 is libc log
which is void
34 is FdAlloc, which allocates a file handle
and 35 is FdOpen
which fails with 0xb
aka OBOS_STATUS_NOT_FOUND
it tried to open /etc/passwd
I wonder if that's a problem
so other than that failed open, all else is fine
until it ultimately exits the thread
causing the "hang"
[ LOG ] writing shell-init: error retrieving current directory: getcwd: cannot access parent directories: Operation not implemented (ENOSYS)
to stderr```
I also added logs of writes to stderr/stdout
[ LOG ] writing init: initialize_job_control: getpgrp failed: Operation not implemented (ENOSYS)
to stderr```
ah yeah I forgot about that one, it assumes that getcwd is broken by default when cross compiling and uses its own impl
Lol
bash_cv_getcwd_malloc=yes to the end of the ./configure line
./configure --host=whatever --without-bash-malloc bash_cv_getcwd_malloc=yes
ah
btw when I run make install I get linker errors
here
which I found weird
pretty sure it should use crtbeginS.o for a shared library 
relocation R_X86_64_32 against hidden symbol '__TMC_END__' can not be used when making a shared object
well adding that removes the getcwd error
but still no prompt 
[ LOG ] syscall 37(0x2, 0xcf8008, 0x51, 0x916060, 0x0)
[ LOG ] writing init: initialize_job_control: getpgrp failed: Operation not implemented (ENOSYS)
to stderr
[ LOG ] syscall 37 returned 0x0000000000000000
[ LOG ] syscall 42(0x0, 0x0, 0x0, 0x0, 0x0)
[ LOG ] syscall 42 returned 0x0000000000000000
[ LOG ] syscall 41(0x0, 0x0, 0x1, 0x0, 0x0)
[ LOG ] syscall 41 returned 0x0000000000000000
[ LOG ] syscall 42(0x0, 0x0, 0x0, 0x0, 0x0)
[ LOG ] syscall 42 returned 0x0000000000000000
[ LOG ] syscall 42(0x0, 0x0, 0x0, 0x0, 0x0)
[ LOG ] syscall 42 returned 0x0000000000000000
[ LOG ] syscall 41(0x0, 0x0, 0x1, 0x0, 0x0)
[ LOG ] syscall 41 returned 0x0000000000000000
[ LOG ] syscall 42(0x0, 0x0, 0x0, 0x0, 0x0)
[ LOG ] syscall 42 returned 0x0000000000000000
[ LOG ] syscall 42(0x1, 0x0, 0x0, 0x0, 0x0)
[ LOG ] syscall 42 returned 0x0000000000000000
[ LOG ] syscall 41(0x1, 0x0, 0x1, 0x0, 0x0)
[ LOG ] syscall 41 returned 0x0000000000000000
[ LOG ] syscall 42(0x1, 0x0, 0x0, 0x0, 0x0)
[ LOG ] syscall 42 returned 0x0000000000000000
[ LOG ] syscall 42(0x1, 0x0, 0x0, 0x0, 0x0)
[ LOG ] syscall 42 returned 0x0000000000000000
[ LOG ] syscall 41(0x1, 0x0, 0x1, 0x0, 0x0)
[ LOG ] syscall 41 returned 0x0000000000000000
[ LOG ] syscall 42(0x1, 0x0, 0x0, 0x0, 0x0)
[ LOG ] syscall 42 returned 0x0000000000000000
[ LOG ] syscall 42(0x2, 0x0, 0x0, 0x0, 0x0)
[ LOG ] syscall 42 returned 0x0000000000000000
[ LOG ] syscall 41(0x2, 0x0, 0x1, 0x0, 0x0)
[ LOG ] syscall 41 returned 0x0000000000000000
[ LOG ] syscall 42(0x2, 0x0, 0x0, 0x0, 0x0)
[ LOG ] syscall 42 returned 0x0000000000000000
[ LOG ] syscall 0(0x0, 0x0, 0x0, 0x0, 0x0)
syscall 0 is exit current thread
syscall 42 is fd tell off
syscall 41 is fd seek
syscall 37 is fd write
and none of these syscalls fail...
try stubbing getpgid
lol
last thing it says is [ LIBC ] mlibc: sys_getegid is a stub!
then SIGILL
I stubbed that and made it return 0
I removed the fake stub
and now mlibc panics
[ LIBC ] In function getegid, file ../options/posix/generic/unistd.cpp:1110
__ensure(Library function fails due to missing sysdep) failed
[ LOG ] syscall 57 returned 0x00000000c404a2cf
[ LOG ] syscall 57(0x916b98, 0x0, 0x0, 0x0, 0x0)
[ LIBC ] In function getegid, file ../options/posix/generic/unistd.cpp:1111
__ensure(!"Cannot continue without sys_getegid()") failed
[ LOG ] syscall 57 returned 0x00000000c404a2cf
[ LOG ] syscall 57(0x412aa0b8, 0x0, 0x0, 0x0, 0x0)
[ LIBC ] mlibc panicked! exiting program...
[ LOG ] syscall 57 returned 0x00000000c404a2cf
[ LOG ] syscall 0(0x0, 0x0, 0x0, 0x0, 0x0)
so I put the stub back
and ofc it SIGILLed
like it did before
I found the problem
that caused SIGILL
I was forgetting to return a value in a stubbed sysdep
I get a prompt, to an extent
it just throws in exit
did you make pselect return 1 in num_events?
then it also tries to read stdio after that
so if you don't return anything (or return zero read bytes) it might fail
wait I do
it was an ancient bug in my uart driver
where it doesn't block in a function that should block
at least, iirc I didn't fix it
this is in sys_read right?
or is it in pselect
yes
int sys_pselect(int num_fds, fd_set *read_set, fd_set *write_set, fd_set *except_set, const struct timespec *timeout, const sigset_t *sigmask, int *num_events)
{
*num_events = 1;
return 1;
}
you should make it return 0, 1 indicates a failure
oops
it uses pselect to wait for input and then after that reads from stdio
why is bash seemingly trying to read zero bytes
nvm
it's trying to read one, but I have a bug somewhere in fd read
fuck clang
while(port->in_buffer.szBuf < blkCount)
;```
it optimized this loop into an infinite loop
FINALLY
bash
except I don't have fork so nothing happens 
but hey the exit command works 
better than on my kernel, I haven't yet added proper stdio read
just get a serial driver
my stdin opens /dev/COM1
void OBOS_OpenStandardFDs()
{
handle hnd_stdin = Sys_FdAlloc();
handle hnd_stdout = Sys_FdAlloc();
handle hnd_stderr = Sys_FdAlloc();
OBOS_LockHandleTable(OBOS_CurrentHandleTable());
obos_status status = OBOS_STATUS_SUCCESS;
handle_desc* stdin = OBOS_HandleLookup(OBOS_CurrentHandleTable(), hnd_stdin, HANDLE_TYPE_FD, false, &status);
handle_desc* stdout = OBOS_HandleLookup(OBOS_CurrentHandleTable(), hnd_stdout, HANDLE_TYPE_FD, false, &status);
handle_desc* stderr = OBOS_HandleLookup(OBOS_CurrentHandleTable(), hnd_stderr, HANDLE_TYPE_FD, false, &status);
OBOS_UnlockHandleTable(OBOS_CurrentHandleTable());
Vfs_FdOpen(stdin->un.fd, "/dev/COM1", FD_OFLAGS_READ);
Vfs_FdOpen(stdout->un.fd, "/dev/COM1", FD_OFLAGS_WRITE);
Vfs_FdOpen(stderr->un.fd, "/dev/COM1", FD_OFLAGS_WRITE);
}```
yeah that would be the easiest option
you can also build bash without readline
ah lol
what the hell is happening lol
the first command ran is the only one that runs
so if I did echo hi as the first comamnd
echo hi is the command that works
through out the entire session
why are you using putty
cuz
I have qemu set to put serial on localhost:1534
so I'm using putty to connect to that
you can access the monitor via the gui anyway
fair
nvm, bash sometimes wants to run a comamnd
*command
sometimes it decides not to
I assume comamnds like ls are in coreutils, right?
as well as cat
yes
I have a bug which idk how to solve
so I segfault after a GPF
when I pass a 2nd argument to the program
i.e., argc=2
I look into it, and it faults on an instruction where the pointer passed should be aligned to a 16-byte boundary
movaps %xmm0, -0x20(%rbp)
but rbp=0x00000000009129d8
and I can't align the stack when I hand off the program to the dynamic loader, because then it can't see the aux values
and panics
? the aux values don't change alignment
the only thing to account for is argc + argv[] + null + envp[] + null
and you can account for that before pushing the auxv by pushing an extra 0 if needed
using bash --verbose, I discover that it's because sometimes there are missing bytes
in stuff read from the serial driver
as can be seen here
anyway, now that I have bash, I want to continue making the thing
obos-strap
I implement the signal-related sysdeps
so I decided to try it out using kill -s SIGINT 6
(6 is the main thread of the bash process)
but then disaster strikes 
and of course in a debugger, this doesn't reprod
dayum
meanwhile im over here struggling with scheduler UB STILL
@flint idol good progress though happy u reached bash
!!
what significant feature do you want it to have
nothing
asking so i can implement it in nixstrap
I was in bed yesterday and thought that would be fun to try out
i want nixstrap to be able to generate runners
and i want a helper application for nixstrap
so i can nixstrap configure or something to set qemu args
then it will generate a shell script for that
and maybe i could put that in home manager
and i can have a script like gbox run
generated automagically
tomorrow i might work a couple hours on mlibc in nixpkgs
use obos-strap 
when it comes out
lmao
do your own thing
also i want ISOs in nixstrap
that's probably gonna somehow end up deleting your entire root
it can only generate raw disk images rn
like it is somehow gonna do rm -rf --no-preserve-root /
nyauxstrap rm -rf --no-preserve-root /
if @thick jolt tried to make a package manager

or whatever these are called
just use jinx
disko supports various VM image formats so that's a very simple addition to nixstrap but ISOs are a problem
#1279525023127830609 and scroll up
it's cool because
- you can use the entirety of nixpkgs (which is super useful for bootloaders and stuff, and if you add your OS as a supported platform in nixpkgs you can probably get userspace apps from nixpkgs as well, and if you're ABI compatible with linux you can get unpatched linux software from there
- declarative and modular (it's like using nixos modules, and several modules are provided by nixstrap by default like installing limine or generating limine.conf or stuff for image generation
- you get a lockfile and nix has reproducibility guarantees
oh yeah for obos-strap I had the brilliant idea of using... named semaphores for locking
- and you can spin up a nix cache server like how NixBSD has one to cut down on compile times for your contributors
i don't think jinx and nixstrap are the same thing and the same purpose tbh lol
neither do i
just like xbstrap is different and not comparable to jinx
jinx is literally called so because of xbstrap tho
i mean using one would replace the other right?
jinx and xbstrap are comparable
yes but it literally means "jinx is not xbstrap" :^)
however different they may be they do the same core thing
which is to bootstrap an OS or distro
yeah sure
jinx vs nixstrap is basically ABS (arch) vs nix
in that sense they are comparable, fair
anyhow the only time i tried building managarm
i got frustrated over xbstrap
i don't remember why tho
jinx worked every time i used it for other OSes here but i never used it for a project of mine (none of them progressed to that point
jinx W
yep thanks for your work on jinx
i may be a nixstrap evangelist but i appreciate jinx
jinx is what inspired nixstrap's predecessor which i probably didn't mention here at all
that predecessor was lever and it was a build system / os bootstrapper written in lua & rust with recipes in lua and it used udisksctl for mounting and image generation
then i tried making it at least somewhat reproducable
and i got really mad
then scrapped it and did nixstrap
i say "lua" but it was more a dialect of lua where unresolved functions spawned the program in path with the name of that function and it had ""pipelines"" so you could do cat("test.txt"):tee("foo.txt")
anyhow happy new year
❤️
likewise
I think it's time to merge https://github.com/OBOS-dev/obos/pull/27
small changes
16k insertions, wow you've done a lot in the week that branch has existed
this branch has existed for 5 months
*4 months
it's just that the PR was made 1 week ago
indeed
hello from 2025
it is not 2025
Is 2025 finally the year of the linux desktop
90% desktops running Linux this year????
i mean i have yet to use windows
so for me
all desktops (and laptops) have been running linux
I do not recommend it
he's a time traveler
i have knowledge from the future
ask me what you want to know
i should probably be in another channel tho
will I get into the uni I want
What will happen to Syria
iraq 2.0 let's hope someone doesn't accidentally kill 1.5 million
i need details on who you are
give me SSN or ID number or whatever
exact location
birth date and time
full legal name
1234 5678 is ID number
the numbers on your card
123 sesame street
invalid
9/11/2001 at aroud 7am
Ben Dover
Georgia, Tbilisi
Birth date: April 20 1889
Full name: albus percival wulfric brian dumbledore
ID: 6942069420
americans use MM/DD
you will move abroad
to baguette land
or terf island
which one is that
ah
merged
@thick jolt you are now in the contributors list
now time to see if it even compiles
yay
after some compiler errors were fixerd
it compiles
but it PFs
but with the pretty panic screen
I made a few months ago
damn it
it works on debug mode
but not release
meaning I've UB
I guess I will be git diffing
to find the problem
the commit ID starts with bad...
it's git's fault then 
I need to git commit --amend to remake the commit's hash
then the problem is solved
fixed that seemingly
oh wait it's UB
that's not how it works
Is 2025 the year of bash on obos
What are 2025 goals
Self hosting?
it's not the lack of syscalls really, it's the lack of sysdeps
Even easier
the only syscalls I can even think of needing rn are:
- TTY syscalls
- tgkill
- sockets
I also need dup(2)
symlink syscalls
I need file creation/removal
I need poll
at least you have signals
although I already have pipes, I need to add syscalls for them
true
except none, but the "exception" signals are automatically sent by the kernel as of now
and by exception signals I mean SIGSEGV, SIGILL, SIGFPE, SIGTRAP
timer related syscalls as well
int sys_waitid(idtype_t idtype, id_t id, siginfo_t *info, int options);```
probably this too
also process group related syscalls probably
tldr: everything lol
out of the 60 syscalls I have, almost none I have are used
by mlibc
so that's something
there are actually a huge ton of functions in posix, I hadn't realized that before I wrote my own libc
Crescent is like the good serenityos
how lol
do you have execve?
so you can execute something, but you can't still have a process after starting a new one
what execve does is make the current pid have an identity crisis
More competent
which thus causes it to change itself into a new process
fork starts a child process that is effectively a clone of the current one
I find it weird that you have execve, but not fork. You can start a new program, but the current one has to die in the process.
after fixing these bugs, I will:
- implement the execve sysdep
- implement fork
- implement fork sysdep
well many moons ago I decided to do it, but then I stopped after having finished the VMM part
so I have mm/fork.h defining Mm_ForkContext
/*
* oboskrnl/mm/fork.h
*
* Copyright (c) 2024 Omar Berrow
*/
#pragma once
#include <int.h>
#include <error.h>
#include <mm/context.h>
obos_status Mm_ForkContext(context* into, context* toFork);
but no Sys_Fork
fork is a pain, so I can understand why you would abandon it
yup
tbh I don't even know much about serenity, I haven't really looked much into it (well I do know what it is and whatever but more than that) 
Well crescent is like serenity because full nih
Is what I meant
although the hard part which, to most people appears to be the VMM part, is the only part I did
ah
And c++
I should also implement that but I still don't even have demand mapping 
and I hate fork with passion
same
yet it's the only way with mlibc (unless mlibc has a clone sysdep)
afaict
or you just patch the usages of fork within everything you want to port
I could probably do fork in userspace without much trouble
as long as I expose Mm_ForkContext, of course
since any file descriptors appear to be closed
fork isn't that bad
No? Fork copies the fds
oops
Fork is an exact copy of the parent process basically
Which is why execing directly after is kinda stupid
Because you throw it all away (apart from fds)
iirc they are
as in, fds are thrown away
but I will check the man page for htis
*this
Inherited from init
I misread my execve code
Is o_cloexec a joke to you 
if (tbl->arr[i].un.fd->flags & FD_FLAGS_NOEXEC)
Sys_HandleClose(i | (tbl->arr[i].type << HANDLE_TYPE_SHIFT));```
no
(this is in execve code)
((in a loop freeing handles))
What if there's another thread in this process opening fds at the same time
Do u protect against that
good thing you reminded me to that
because I should be locking the handle table in that loop
actually, nvm
all other threads of that process would be killed by then
for (thread_node* curr = Core_GetCurrentThread()->proc->threads.head; curr; )
{
thread* const thr = curr->data;
curr = curr->next;
if (thr == Core_GetCurrentThread())
continue;
OBOS_Kill(Core_GetCurrentThread(), thr, SIGKILL);
while (~thr->flags & THREAD_FLAGS_DIED)
OBOSS_SpinlockHint();
}```
according to this loop
U sure thats compliant behavior? 
I think I remember reading threads of the process are not preserved
Makes sense for exec, but are u supposed to kill them with sigkill
Anyway that's a separate issue
it only becomes a problem when it breaks something
lmao
anyway I need to fix this bug
before new year where I am
I need to get obos' fireworks test working
Like userspace?
Didnt u have that test Workin
yes
I merged userspace-work
causing regressions
and crashes while loading some other driver
because of ||memory corruption||
(obos curse always returns)
💀
I am currently checking the diff to find out where I went wrong
Astral is like serenity (in implementation
)

Well no
I'm going to start copy pasting files from before I merged the branch until something changes
astral has working smp
no mutexes taken under spinlocks
ext not corrupting itself after making 2 files
wait serenity doesn't even have working smp?
bru
I suspect it's something silly like me forgetting to pass a correct size to Free
What the fuck
They never bothered stabilizing it
the crash specifically is in Mm_Allocator
at least I have been trying to keep my kernel relatively stable fixing all bugs that I find even if they only happen once in a large number of boots
Exactly
Literally how
that's what I am trying to figure out
luckily for my sanity, it seems to prod every boot in around the same place
nBytes = (size_t)1 << (64-__builtin_clzll(nBytes));```
this code is correct to round up size to the nearest power of two, right?
Just copy astral's slab, bam no more allocator bugs 
I also found out funny bugs in my vmem today (or well yesterday, its 3:14 here already) that happen when you pass in a min addr + max addr (like I did for MAP_FIXED when splitting regions), it only looked at a freelist one order higher than where the free was put at because the size wasn't power of two 
F
but why would it be an allocator bug if the allocator worked in the exact same configuration, but before merging master
yes, though its going to overallocate if the size is exactly power of two
that's also easy to fix, just pass it nBytes - 1
I'll fix that after fixing the bug
though you do have to make sure that nBytes is >= 2 when you do that or otherwise you get UB
the size is rounded up to 16 if it's < 16
so that's fine
weirdly that gets the kernel to boot further
where it then crashes in the non paged pool allocator
but the weirdest part about this bug is the fact that it crashes here:
remove_node(c->free, c->free.tail);```
(remove_node is a macro)
I guess I need kasan now
obos doesn't build on GCC anymore
it complains about symbols that should be defined
which in fact are defined
in a static library
fixed
TIL you can use lto to get extended results from -fanalyzer
wait nvm
so yeah this all worked perfectly fine before the merge
after I made sure
uh
when I add printfs it no longer crashes
Ub!!!!! :D
which doesn't say much
I can reproduce on gcc
ubsan doesn't complain
but everytime it faults, it faults here:
remove_node(c->free, c->free.tail);```
what the hell
c->free.tail->next is non-null
which can only mean one thing, memory corruption
specifically it's some random address in the kernel
amazing, under a debugger the bug goes away
@flint idol what even is your reasoning for having ipl be a per thread thing
Irql
Whatever you call it
idr, it was a decision I made months ago
and never bothered to document in any way, shape, or form
ub is so fun 🥰
especially when UBSan catches nothing
nor does an entire static analyzer
I thought you had escaped the worst of your curse in this kernel, but obviously not
ok I got it to reproduce in a debugger
I was able to find a bug
I was freeing an object with a different allocator than the one I was allocating with
fixed
for future reference, always free with the same allocator you allocate with
but I swear this is the third time I've fixed the exact same bug
this same bug happened in the same file, but in a different context
and I had fixed it in commit b5462267e9d71dd76e63323509d524b95a908515
Why do u have multiple alligators
sorry, alligators?
Allocators
oh allocators
one is for the memory manager
one is for allocating non-paged memory
one is for allocating "normal" memory
that design is shit, I hate it
and I do wish I hadn't done it
but now I'm stuck with it
that is unless I want to replace 633 occurences of allocation with a new interface
however, they all have the same underlying implementation, except for the fact that they map memory differently
please just have a slab allocator then a vmm address space allocator
simple
simple dimple
go away
yes it would
but this
||get to work /j||
seriously tho maybe i could help with that tmrw
ill see
I don't plan on doing that anytime soon
understandable
the commit would be at least +633 -633
changes
just to change it to use the new interface
fair
if I were to make a new interface, it would look like:
enum {
ALLOCATOR_REGION_GENERAL,
ALLOCATOR_REGION_NON_PAGED,
ALLOCATOR_REGION_VMM,
};
void *OBOS_Allocate(size_t sz, uint32_t alloc_region);
void *OBOS_ZeroAllocate(size_t cnt, size_t sz, uint32_t alloc_region);
void OBOS_Reallocate(void* what, size_t new_sz, size_t old_sz);
void OBOS_Free(void* what, size_t sz);```
I was able to get the obos fireworks test working again
posix_spawn?
I have been working on substituting certain strings in commands for others (like variables ig) in obos-strap
(example) "${nproc} $PWD $DISPLAY"
${varname} substitutes a preset variable (e.g., prefix directory) with it's actual value
Example: ${nproc} would get substituted with the amount of processors on the system
Example: ${prefix} would get with a full path to the prefix
$ENV_NAME is substituted with whatever the value of ENV_NAME is
Example: $PWD gets substituted with the current working directory
hopefully I can get this tool working by the end of today, although it won't be the fanciest, I don't really care
as I can always expand it
struct stat st = {};
if (stat(pkg->name, &st) == -1)
mkdir(pkg->name, 0666);
int dir_fd = open(pkg->name, O_DIRECTORY);
printf("Entering directory %s\n", pkg->name);
if (fchdir(dir_fd) == -1)
{
perror("chdir");
return false;
}```
because bah, this `fchdir` fails with EACCES
because "Search permission was denied on the directory open on fd." according to the manpage
but the question is how I allow it
you need to allow execution within the directory
np
I just built the first test package using obos-strap
{
"name": "hello",
"description": "Print a friendly, customizable greeting.",
"url": "https://ftp.gnu.org/gnu/hello/hello-2.12.1.tar.gz",
"depends": [],
"patches": [],
"bootstrap-commands": [
[ "${repo_directory}/hello-2.12.1/bootstrap" ],
[ "${repo_directory}/hello-2.12.1/configure", "--prefix", "${prefix}" ]
],
"build-commands": [
[ "make", "-j${nproc}" ]
],
"install-commands": [
[ "make", "install" ]
]
}
next up is supporting git-url and git-commit
which is for cloning
its a variable
the point is that you dont want to use -j anything
I know, it's just there in case something needs it
you want to parallel build multiple packages
and I was testing substitution
and not build one package in parallel
TODO:
eh
because that is significantly faster
because it lets you parallelize configure
or alternatively you want to run with -j but with a custom jobserver that limits concurrency at the global level
it also depends on the packages whether its faster, with autogarbage ones sure but if they use cmake/meson the configure time is usually insignificant
when I do parallel package builds, I will need to make sure that if two+ packages depend on the same thing (i.e., bash and coreutils depending on mlibc), that only one of them builds the mlibc package
yes
yeah but autogarbage is like
most of the stuff you build
but thats easy enough to do
ye
you build a dep graph
you make sure that it is acyclic
and then when you finish building a package P, for each package Q where P is in Q.depends, you decrement Q.num_missing_deps
and if Q.num_missing_deps == 0 then you add it to the queue
repeat until the queue is empty
maybe I should do something like that too with some kind of way to indicate that a package uses all parallelism on its own (for use in packages like llvm)
or well ig you could monitor cpu usage and do it automatically, idk how hard would that be to do (as you'd have to take into account that there might be spikes in usage too)
you can use the jobserver protocol
every build system worth its salt handles it
and that lets you limit concurrency globally
make, ninja, cargo do at least
and other ones dont exist anyway
shell script 
does ninja? I only see it in a pr
if it doesnt that would suck
/*
* build - DONE
* clean - DONE
* buildall - TODO
* rebuild - DONE
* setup-env - DONE
* force-unlock - DONE
* install - DONE
* installall - TODO
* chroot - DONE
* git repos - TODO
*/```
I am nearly done the base of `obos-strap`
before it becomes usable for OBOS
for git repos is it really worth it to use a library like libgit2
I would probably save a lot of time if I just used the git command
within my C code
do you do stuff in a container?
cringe
static bool extract_archive(const char* url, const char* name, char* archive_path)
{
// TODO: Use a library?
string_array argv = {};
string_array_append(&argv, "tar");
string_array_append(&argv, "-xf");
string_array_append(&argv, archive_path);
int ret = run_command("tar", argv);
if (ret != EXIT_SUCCESS)
printf("Could not run program 'tar'. Exit status: %d\n", ret);
return ret == EXIT_SUCCESS;
}```
just like how I decided I couldn't be damned to use a library to extract the archive
yeah ik
go or rust would be fine here
yeah
even python
i was about to suggest go and rust
doesnt need speed
python no
I don't know neither go, rust, nor python
python is significantly slower
I've done a similar tool before in python 
something something learning
bah
you should learn go
wonder if there's some kind of cross platform container library thing
I mean you could just call podman too
docker api lmao
yeah but like
some kind of library that spins up VMs on e.g macOS
yea
which sucks already
or podman
or podman
podman handles it already
yeah docker too
no you need docker desktop on macOS
they both have nice go apis too
same thing
podman you can just do podman machine init/create
system("qemu-system-aarch64 -drive file=macos.img,format=raw")

thats shitty and slow
hm
but even then that sucks
maybe that is a viable option
theres a go api
because you cant have multiple machines started/created
which one doesnt
anyway, I already wrote this code, and I don't wanna rewrite it, so when I want to deshittify this, I will do so
push to github and run a workflow
there is a literal package named github.com/containers/libpod/v2
idk the python one didnt
and it's like the official one
podman logo
the go shit is official too
yeah idk
i should try the podman bindings
*it's not like anyone even is missing tar on their systems anyway
*
the docker ones suck ass
they dont support this
so you need to call it yourself
which suuuucks
here's my attempt
not that bad, but it's a bunch of calling the shell
there's a recipe example in recipes/hello.json
does everyone use gnu hello for testing their bootstrap thing
{
"name": "hello",
"description": "Print a friendly, customizable greeting.",
"url": "https://ftp.gnu.org/gnu/hello/hello-2.12.1.tar.gz",
"depends": [],
"patches": [],
"bootstrap-commands": [
[ "${repo_directory}/hello-2.12.1/bootstrap" ],
[ "${repo_directory}/hello-2.12.1/configure", "--prefix", "${prefix}" ]
],
"build-commands": [
[ "make", "all" ]
],
"install-commands": [
[ "make", "install" ]
]
}```
because that's my test thing
hmm maybe I should merge bootstrap and build steps
they are done right after each other in the build code anyway, so merging them simply removes some complexity from the recipe
I think this was good
yeah it looks good
anyway, I will be implementing these stuff next:
- git repo fetching (may or may not just run a
gitcommand or two) - buildall command
- installall command
then I will make some recipes for obos probably
and I'll be making these recipes
- bootstrap-gcc
- mlibc
- gcc
- bash
bootstrap-gcc is with inhibitLibc=true
mlibc is built with that
then gcc is built with mlibc
then bash is built with mlibc+gcc
ig
so:
gcc: depends mlibc
mlibc: depends bootstrap-gcc
bash: depends gcc, mlibc
bootstrap-gcc: no dependencies
and thinking about it, I might want to separate host recipes and target recipes
which I will do after I add git repository fetching
dont do git really
just do tarballs
but then how do I apply target-specific changes to the thing
to the downloaded tarball
you can apply patches as normal
what does that mean
probably a stupid question
??
using patch ?
oh that exists
bruh
silly me
patches existed way before git did
well obviously
yeah I will be adding git in case I somehow come across a tool/thing I want to port without a tarball
which sounds unlikely, as anything that is on github and has a release will have a tarball
but just in case
even then everything on github is tarballed iirc
like you can fetch a tarball of a repo even without it being published (the tarball, that is)
.
no need for releases
