#OBOS (not vibecoded)

1 messages · Page 32 of 1

flint idol
#
../options/posix/generic/posix_stdlib.cpp:11:10: fatal error: sys/ioctl.h: No such file or directory```
#

from mlibc

#

do I need to define that myself?

weary hound
#
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 meme

flint idol
#
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

real pecan
#

Think hard

weary hound
#

that's not the line

flint idol
#

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

weary hound
#

no

flint idol
real pecan
flint idol
#

korona?

lean glen
#

no

#

we dont know who that guy is

#

he's a random contributor

#

his name was only heard of in legends

real pecan
weary hound
#

re. geert, i want you to start typing in @ geert without the space (maybe not in here but in a normal channel)

flint idol
#

I'm sorry I'm not up to date with all the managarm lore

lean glen
real pecan
#

Sorry trl

lean glen
#

geert is

flint idol
weary hound
#

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 meme

flint idol
#

ok (I feel like I will regret that)

#

doesn't build

white mulch
#

yeah that should be fixed, for now you can just add a #define _GNU_SOURCE on top of that file I think

weary hound
#

hmm

flint idol
#

maybe I should just yoink sys/ioctl.h

weary hound
#

i think _GNU_SOURCE should be getting defined by the compiler?

flint idol
white mulch
#

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

weary hound
#

i mean this builds on ci and on managarm

#

and for other oses

flint idol
real pecan
#

Obos is a bsd confirmed

flint idol
#

lol

real pecan
#

Obosd

flint idol
#

obsd

weary hound
#

hm that's missing an ifdef around it

#

checking for __MLIBC_BSD_OPTION

flint idol
#

and it turns out I can't just yoink that header

#

and I need the glibc option

#

it compiles now

white mulch
weary hound
#

possibly

#

we should probably build more combinations of options on ci

#

like ansi+posix without glibc,bsd,etc

vale nymph
#

yeah mlibc is kinda iffy when missing a few options

flint idol
#

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?

weary hound
flint idol
#

I will reinstall it

#

just in case

#

that was the problem

vale nymph
#

bash soon??

flint idol
#

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
weary hound
#

there's an option to enable a stub libdl.so iirc

flint idol
#

in mlibc?

weary hound
#

it doesn't provide anything but exists for programs that want it

#

yeah

flint idol
#

it seems to be enabled by default...

vale nymph
#

if its in /usr/lib in the sysroot then your open or stat syscall is bad, sorry

flint idol
#

what stat syscall KEKW

vale nymph
#

\s/stat/whatever your stat syscall is

flint idol
#

(I have no stat syscall)

#

well fucking lucky me

#

it exists

vale nymph
#

get a syscall log and see what happends

flint idol
#

ah I see what's happening

#

I forgot to null terminate a string

vale nymph
#

xd

flint idol
#

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...```
vale nymph
#

U can return 0

#

For that

flint idol
#

ye

#

what's the difference between ppid and pid

#

found the answer

vale nymph
#

Haha pp

flint idol
#

hahahhaha

#

look under there

under where?

HAHAHA made you say underwear

#

what's the difference between sys_getpid and sys_getpgid

vale nymph
flint idol
#

so bash needs it?

#

or bash only needs it for job control stuff

vale nymph
#

You can just stub it as like 1 or something

#

Only for job control yeah

flint idol
#

thanks

vale nymph
flint idol
#

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

flint idol
#

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

empty kernel
#

you still have 1 more day left in the year

flint idol
#

yes

#

(1 day EST)

#

so 24 hours 30 minutes

empty kernel
#

yeah, I've only got 9 and a half hours left in the year

flint idol
thick jolt
#

while ur having fun omar, im experiencing scheduler ub

#

bro is doing the fun part

flint idol
thick jolt
#

of porting

empty kernel
thick jolt
#

cant sleep

thick jolt
#

its so fun

flint idol
#

when it exists

thick jolt
#

how about u deal with scheduler UB trl

flint idol
#

I have, don't worry

thick jolt
#

even worse

#

like bro i just added thread states like running, ready, and zombie

#

crazy

flint idol
#

a day or two I had to debug the scheduler

thick jolt
#

what was ze issue for u

flint idol
#

specifically the context switching

flint idol
empty kernel
flint idol
#

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

flint idol
#

aka gcc built with inhibitLibc=true

#

anyway gn

thick jolt
#

nightnight

lean glen
#

I don't have it

#

And bash works fine

flint idol
#

Hm

flint idol
lean glen
#

Because you fucked up

flint idol
#

Makes perfect sense

flint idol
#

I just love my isatty implementation

limber wave
flint idol
#

@vale nymph help

#

pls

#

I decided to remove my "isatty" implementation

#

and stub it out

#

but now bash just exits without doing any prompt

vale nymph
#

y stub it out

flint idol
#

so I figured I should just stub it instead

vale nymph
#

implement it properly lol

white mulch
#

see lib/readline/input.c:833

flint idol
#

I'll try that

white mulch
#

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

flint idol
#

I did that, still no prompt :(

white mulch
#

did you also restore your original isatty stub

flint idol
#

no

white mulch
#

try that

flint idol
#

still no prompt

#

I get a bunch of missing sigaction sysdeps

#

maybe I should fix that

vale nymph
#

not really needed for bash

#

@flint idol get a syscall log

#

something somewehre is failing

#

did you compile it for readline?

flint idol
#

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

flint idol
#

this will take a bit, as I need to implement syscall logging

vale nymph
#

hmmm probably it is using readline

#

for readline you need poll

#

if poll fails it exits

#

does mlibc complain about an unimplemented poll?

flint idol
#

I was able to get it to stop exiting

white mulch
#

I didn't get any polls either

flint idol
#

that's all the unimplemented sysdep things I got

vale nymph
#

something is erroring out which bash doesnt like lol

flint idol
#

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```
white mulch
real pecan
#

Lol

flint idol
#

how do I get it to.. not?

#

I had noticed that in config.log, and assumed whatever

white mulch
#

bash_cv_getcwd_malloc=yes to the end of the ./configure line

flint idol
#

the ./configure line?

#

or do you mean file

white mulch
#

./configure --host=whatever --without-bash-malloc bash_cv_getcwd_malloc=yes

flint idol
#

ah

weary hound
#

you can also export that on the env instead

#

when invoking configure

flint idol
#

btw when I run make install I get linker errors

white mulch
#

pretty sure it should use crtbeginS.o for a shared library thonk

flint idol
#

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 thonk

#
[  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...

white mulch
#

try stubbing getpgid

flint idol
#

ok

#

I'm also going to make sys_thread_exit hang

flint idol
white mulch
#

lol

flint idol
#

but it gets further than last time

#

seemingly

white mulch
#

does it say anything about it

#

or does it just die

flint idol
#

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

white mulch
#

did you make pselect return 1 in num_events?

flint idol
#

yes

#

wait no

white mulch
#

then it also tries to read stdio after that

#

so if you don't return anything (or return zero read bytes) it might fail

flint idol
#

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

flint idol
#

or is it in pselect

white mulch
#

yes

flint idol
#
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;
}
white mulch
#

you should make it return 0, 1 indicates a failure

flint idol
#

oops

white mulch
#

it uses pselect to wait for input and then after that reads from stdio

flint idol
#

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 KEKW

#

but hey the exit command works KEKW

white mulch
#

better than on my kernel, I haven't yet added proper stdio read

flint idol
#

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);
}```
white mulch
#

yeah that would be the easiest option

flint idol
#

time to implement fork

#

@thick jolt guess who has bash now!!11

lean glen
white mulch
#

ah lol

flint idol
#

wait what

#

wtf

#

removing syscall logs changed

#

the behaviour

#

of bash

lean glen
#

pro tip: ./configure --help

#
  • grep
flint idol
#

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

lean glen
#

why are you using putty

flint idol
#

cuz

#

I have qemu set to put serial on localhost:1534

#

so I'm using putty to connect to that

lean glen
#

just

#

-serial stdio

flint idol
#

stdio is taken

#

by the monitor

lean glen
#

you can access the monitor via the gui anyway

flint idol
#

fair

flint idol
#

*command

#

sometimes it decides not to

#

I assume comamnds like ls are in coreutils, right?

#

as well as cat

lean glen
#

yes

flint idol
#

k

#

so I'll be porting that next

#

after implementing fork

flint idol
#

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

weary hound
#

? 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

flint idol
#

oh yeah

#

thanks

flint idol
# flint idol

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

flint idol
#

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 KEKW

#

and of course in a debugger, this doesn't reprod

thick jolt
#

meanwhile im over here struggling with scheduler UB STILL

#

@flint idol good progress though happy u reached bash

#

!!

timid elk
flint idol
#

nothing

timid elk
#

asking so i can implement it in nixstrap

flint idol
#

I was in bed yesterday and thought that would be fun to try out

timid elk
#

i want nixstrap to be able to generate runners

timid elk
#

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

thick jolt
#

so work on nixstrap lol

#

im still waiting

timid elk
#

no

#

i will work on it in the summer

thick jolt
#

pulls out glock 19

#

im gonna reach userspace before the summer

timid elk
#

tomorrow i might work a couple hours on mlibc in nixpkgs

flint idol
#

when it comes out

thick jolt
#

lmao

timid elk
#

also i want ISOs in nixstrap

flint idol
#

that's probably gonna somehow end up deleting your entire root

timid elk
flint idol
#

like it is somehow gonna do rm -rf --no-preserve-root /

thick jolt
#

nyauxstrap rm -rf --no-preserve-root /

flint idol
#

if @thick jolt tried to make a package manager

thick jolt
flint idol
#

or whatever these are called

lean glen
timid elk
timid elk
#

nixstrap is cooler ofc but it's not done

lean glen
#

how is nixstrap cooler

#

im genuinely asking

timid elk
#

#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
flint idol
#

oh yeah for obos-strap I had the brilliant idea of using... named semaphores for locking

timid elk
sharp pike
lean glen
#

neither do i

sharp pike
#

just like xbstrap is different and not comparable to jinx

lean glen
#

jinx is literally called so because of xbstrap tho

timid elk
#

i mean using one would replace the other right?

lean glen
#

jinx and xbstrap are comparable

sharp pike
#

yes but it literally means "jinx is not xbstrap" :^)

timid elk
#

which is to bootstrap an OS or distro

sharp pike
#

yeah sure

timid elk
#

jinx vs nixstrap is basically ABS (arch) vs nix

sharp pike
#

in that sense they are comparable, fair

timid elk
#

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

sharp pike
#

jinx W

timid elk
#

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

sharp pike
sharp pike
flint idol
#

small changes

empty kernel
#

16k insertions, wow you've done a lot in the week that branch has existed

flint idol
#

this branch has existed for 5 months

#

*4 months

#

it's just that the PR was made 1 week ago

empty kernel
#

Oh

#

Just noticed that

#

Still lots of progress

flint idol
#

indeed

timid elk
#

hello from 2025

thick jolt
#

it is not 2025

timid elk
#

it is

#

GMT+3

vale nymph
flint idol
#

*obos desktop

weak kestrel
timid elk
#

so for me

#

all desktops (and laptops) have been running linux

weak kestrel
timid elk
#

i wonder how long i can go without windows

#

probably 2 days

#

because school

flint idol
#

I've gone 7 months

#

(best 7 months ever)

timid elk
#

we are in the first month oberrow

#

there's no way you went 7 months

weak kestrel
#

he's a time traveler

timid elk
#

i have knowledge from the future

#

ask me what you want to know

#

i should probably be in another channel tho

weak kestrel
flint idol
timid elk
flint idol
#

Damn it

#

Was hoping to visit it soon

timid elk
#

give me SSN or ID number or whatever

#

exact location

#

birth date and time

#

full legal name

flint idol
#

1234 5678 is ID number

timid elk
#

the numbers on your card

flint idol
#

123 sesame street

timid elk
timid elk
#

will happen

flint idol
flint idol
timid elk
#

tho

weak kestrel
#

Georgia, Tbilisi
Birth date: April 20 1889
Full name: albus percival wulfric brian dumbledore
ID: 6942069420

timid elk
#

americans use MM/DD

timid elk
#

to baguette land

#

or terf island

weak kestrel
timid elk
#

the one on the right

#

the one on the left isn't terf island

#

that's ireland

weak kestrel
#

ah

flint idol
#

merged

#

@thick jolt you are now in the contributors list

#

now time to see if it even compiles

thick jolt
#

yay

flint idol
#

after some compiler errors were fixerd

#

it compiles

#

but it PFs

#

but with the pretty panic screen

#

I made a few months ago

flint idol
#

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

empty kernel
flint idol
#

it's git's fault then meme

#

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

real pecan
#

Is 2025 the year of bash on obos

flint idol
#

yes

#

well 2024 is

#

#1141057599584878645 message

real pecan
#

What are 2025 goals

flint idol
#

idk

#

but I need to get the crashes on master fixed

#

I'm going to use git bisect

real pecan
flint idol
#

seems far out of my reach

#

currently

real pecan
#

Well if your bash already somewhat works

#

All you need is more syscalls

flint idol
#

it's not the lack of syscalls really, it's the lack of sysdeps

real pecan
#

Even easier

flint idol
#

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

white mulch
#

at least you have signals

flint idol
#

although I already have pipes, I need to add syscalls for them

flint idol
#

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

flint idol
#
int sys_waitid(idtype_t idtype, id_t id, siginfo_t *info, int options);```
#

probably this too

#

also process group related syscalls probably

white mulch
#

tldr: everything lol

flint idol
#

out of the 60 syscalls I have, almost none I have are used

#

by mlibc

#

so that's something

white mulch
#

there are actually a huge ton of functions in posix, I hadn't realized that before I wrote my own libc

flint idol
#

I also need the dreaded fork function

#

although I have half of the work for that done

real pecan
white mulch
#

how lol

empty kernel
flint idol
#

yes

#

syscall 56

empty kernel
#

so you can execute something, but you can't still have a process after starting a new one

flint idol
#

what execve does is make the current pid have an identity crisis

real pecan
flint idol
#

fork starts a child process that is effectively a clone of the current one

empty kernel
#

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.

flint idol
#

after fixing these bugs, I will:

  • implement the execve sysdep
  • implement fork
  • implement fork sysdep
flint idol
#

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

empty kernel
#

fork is a pain, so I can understand why you would abandon it

flint idol
#

yup

white mulch
# real pecan More competent

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) KEKW

real pecan
#

Is what I meant

flint idol
# flint idol yup

although the hard part which, to most people appears to be the VMM part, is the only part I did

real pecan
#

And c++

white mulch
#

and I hate fork with passion

flint idol
#

yet it's the only way with mlibc (unless mlibc has a clone sysdep)

#

afaict

white mulch
#

or you just patch the usages of fork within everything you want to port

flint idol
#

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

lean glen
#

fork isn't that bad

lean glen
flint idol
lean glen
#

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)

flint idol
#

iirc they are

#

as in, fds are thrown away

#

but I will check the man page for htis

#

*this

lean glen
#

No

#

Unless they're marked cloexec

#

That's how stdio works

flint idol
#

oh yeah

#

oops

lean glen
#

Inherited from init

flint idol
#

I misread my execve code

real pecan
#

Is o_cloexec a joke to you LULW

flint idol
#
if (tbl->arr[i].un.fd->flags & FD_FLAGS_NOEXEC)
    Sys_HandleClose(i | (tbl->arr[i].type << HANDLE_TYPE_SHIFT));```
#

no

flint idol
#

((in a loop freeing handles))

real pecan
#

Do u protect against that

flint idol
#

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

real pecan
#

U sure thats compliant behavior? KEKW

flint idol
#

I think I remember reading threads of the process are not preserved

real pecan
#

Makes sense for exec, but are u supposed to kill them with sigkill

flint idol
#

idk

#

it's not like the threads can even do anything about SIGKILL

real pecan
#

Anyway that's a separate issue

flint idol
#

it only becomes a problem when it breaks something

real pecan
#

It breaks my heart

#

(Jk lmao)

flint idol
#

lmao

#

anyway I need to fix this bug

#

before new year where I am

#

I need to get obos' fireworks test working

real pecan
#

Like userspace?

flint idol
#

no

#

(t yet)

real pecan
#

Didnt u have that test Workin

flint idol
#

yes

#

I merged userspace-work

#

causing regressions

#

and crashes while loading some other driver

#

because of ||memory corruption||

#

(obos curse always returns)

real pecan
#

💀

flint idol
#

I am currently checking the diff to find out where I went wrong

vale nymph
flint idol
#

I'm going to start copy pasting files from before I merged the branch until something changes

real pecan
#

astral has working smp
no mutexes taken under spinlocks

#

ext not corrupting itself after making 2 files

white mulch
#

wait serenity doesn't even have working smp?

real pecan
#

Nah

#

It crashes a few seconds after boot

#

Depending on your luck

white mulch
#

bru

flint idol
vale nymph
real pecan
flint idol
white mulch
#

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

real pecan
#

Exactly

flint idol
#

I am afraid this is a.. allocator bug

real pecan
flint idol
#

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?
vale nymph
#

Just copy astral's slab, bam no more allocator bugs meme

white mulch
#

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 KEKW

real pecan
#

F

flint idol
#

but why would it be an allocator bug if the allocator worked in the exact same configuration, but before merging master

white mulch
flint idol
#

that's fine

#

I'd rather it over allocate than under allocate

white mulch
#

that's also easy to fix, just pass it nBytes - 1

flint idol
#

I'll fix that after fixing the bug

white mulch
#

though you do have to make sure that nBytes is >= 2 when you do that or otherwise you get UB

flint idol
#

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

vale nymph
#

Ub!!!!! :D

flint idol
#

indeed

#

I did "test the allocator in userspace"

#

(obos userspace, that is)

flint idol
#

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

vale nymph
#

@flint idol what even is your reasoning for having ipl be a per thread thing

#

Irql

#

Whatever you call it

flint idol
#

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

empty kernel
#

I thought you had escaped the worst of your curse in this kernel, but obviously not

flint idol
#

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

main girder
#

Why do u have multiple alligators

flint idol
#

sorry, alligators?

main girder
#

Allocators

flint idol
#

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

flint idol
thick jolt
#

simple

#

simple dimple

flint idol
#

go away

thick jolt
#

i mean

#

it would work better tho

flint idol
#

yes it would

thick jolt
#

seriously tho maybe i could help with that tmrw

#

ill see

flint idol
#

I don't plan on doing that anytime soon

thick jolt
#

understandable

flint idol
#

the commit would be at least +633 -633

#

changes

#

just to change it to use the new interface

thick jolt
#

fair

flint idol
#

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

flint idol
#

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

flint idol
#
    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

white mulch
flint idol
#

oh

#

thanks qwinci

white mulch
#

np

flint idol
#

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

haughty abyss
#

imagine using json

#

also you dont want -j $(nproc)

white mulch
#

its a variable

haughty abyss
#

yes same thing

#

you dont want that

white mulch
#

no

#

?

haughty abyss
#

the point is that you dont want to use -j anything

flint idol
haughty abyss
#

you want to parallel build multiple packages

flint idol
haughty abyss
#

and not build one package in parallel

white mulch
#

eh

haughty abyss
#

because it lets you parallelize configure

flint idol
#

I will be doing that

#

I just want to get the base build command done

haughty abyss
#

or alternatively you want to run with -j but with a custom jobserver that limits concurrency at the global level

white mulch
#

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

flint idol
#

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

haughty abyss
#

most of the stuff you build

haughty abyss
flint idol
#

ye

haughty abyss
#

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

white mulch
#

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)

haughty abyss
#

every build system worth its salt handles it

#

and that lets you limit concurrency globally

haughty abyss
#

and other ones dont exist anyway

flint idol
#

shell script trl

haughty abyss
#

not parallel

#

so doesnt matter

white mulch
haughty abyss
flint idol
#
/*
 * 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

lean glen
#

do you do stuff in a container?

flint idol
#

no

#

and I don't plan on doing so anytime soon

lean glen
#

cringe

flint idol
# flint idol I would probably save a lot of time if I just used the `git` command
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
lean glen
#

oh

#

god

haughty abyss
#

i agree its kinda cringe

#

also yeah oh god

flint idol
#

yeah ik

haughty abyss
#

also what if you used a good language

#

i.e. not C

lean glen
#

go or rust would be fine here

haughty abyss
#

yeah

lean glen
#

even python

haughty abyss
#

i was about to suggest go and rust

lean glen
#

doesnt need speed

haughty abyss
#

python no

flint idol
#

I don't know neither go, rust, nor python

haughty abyss
#

python is significantly slower

lean glen
#

I've done a similar tool before in python meme

haughty abyss
flint idol
#

bah

haughty abyss
#

you should learn go

lean glen
#

wonder if there's some kind of cross platform container library thing

#

I mean you could just call podman too

lean glen
#

yeah but like

haughty abyss
#

and its only mildly attrociously slow

#

also runc

lean glen
#

some kind of library that spins up VMs on e.g macOS

haughty abyss
#

oh i dont think that exists

#

youd have to mess around with docker

lean glen
#

yea

haughty abyss
#

which sucks already

lean glen
#

or podman

haughty abyss
#

or podman

lean glen
#

podman handles it already

haughty abyss
#

yeah docker too

lean glen
#

no you need docker desktop on macOS

haughty abyss
#

they both have nice go apis too

haughty abyss
lean glen
#

podman you can just do podman machine init/create

flint idol
haughty abyss
#

hm

lean glen
haughty abyss
#

maybe that is a viable option

haughty abyss
lean glen
#

because you cant have multiple machines started/created

lean glen
#

the python one didnt atleast

haughty abyss
flint idol
#

anyway, I already wrote this code, and I don't wanna rewrite it, so when I want to deshittify this, I will do so

weak kestrel
#

push to github and run a workflow

haughty abyss
lean glen
#

and it's like the official one

haughty abyss
#

the go shit is official too

#

yeah idk

#

i should try the podman bindings

flint idol
haughty abyss
#

the docker ones suck ass

lean glen
#

they dont support this

#

so you need to call it yourself

#

which suuuucks

flint idol
#

I do use libcurl, as opposed to running the curl command

#

at least

lean glen
#

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

flint idol
#

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

lean glen
#

I think this was good

flint idol
#

yeah it looks good

#

anyway, I will be implementing these stuff next:

  • git repo fetching (may or may not just run a git command 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

lean glen
#

just do tarballs

haughty abyss
#

do git

#

its the cool thing to do

flint idol
#

to the downloaded tarball

haughty abyss
#

you can apply patches as normal

lean glen
#

what does that mean

flint idol
#

probably a stupid question

lean glen
#

??

flint idol
#

to the extracted tarball

lean glen
#

using patch ?

flint idol
#

oh that exists

lean glen
#

bruh

flint idol
#

silly me

haughty abyss
#

lmfao

#

you should use git though

lean glen
#

patches existed way before git did

flint idol
#

well obviously

lean glen
#

did you think people just applied them by hand?

#

lol

flint idol
#

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

lean glen
#

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)

lean glen
#

no need for releases