#Nyaux
1 messages ยท Page 61 of 1
bit 0 of the command port tells you if there's anything to read
yea i know
you should also flush the keyboard buffer when you initialize the keyboard
ill just the bytes keyboard sends me onto some buffer (reading until there is no more data left), do the state machine until the buffer is no more and then send the eoi
makes sense
just move your current irq handling to a separate function that takes in a byte and replace the irq handler with while (inb(cmdPort) & 0x1) handleByte(inb(dataPort));
yea thats easier
nothing ever happens
this shit is not gonna do anything until next year
nahhhh
it's not like i've been doing it for couple years atp
thats completely wrong lol
the amount of contributions you've done torwards other projects + ur own shit as well
anyways brb i go brush teeth and drink wata
like a british
sounds good
the ps2 buffer is more than one byte?
apparently yes
wtf, what type of cement block have I been living under
nah it's def one byte, the one in the controller
not the keyboard tho it seems
well then maybe it's not a multi-byte buffer
but you should still read until the controller says there's nothing to read anymore
attempting changes now
ok @thorn bramble weird thing, i did the thing u suggested but it just belives theres an infinite number of the byte you pressed? my while loop is correct and i do update scancode so this is weird as shit
lol
wait am i
i dont know
why did u write it so weird
how so
oh yeah
its like u did not read waht i told u
while (inb(cmdPort) & 0x1) handleByte(inb(dataPort));
read again
carefully
exactly
just read
ill just read the status reg for shit
oh yeah status register
lol
pretty much i htink
no it is
yea
idk
yea may be cooked here

still deadlocking with ze mem lock
not epic
i wonder why im not getting any interrupts in general
i feel like kmalloc here is being called after interrupts are disabled in some part of the code
therefore the lock never gets released, nyaux gets stuck and deadlock time
okay i think i may know why, for some reason interrupts are disabled on the mmap syscall
however enabling them explcitly page faults 
rip 0x0 my worst enemy
lmao
most normal page fault
real
not only is demend paging fucked
but if i just dont demend page some weird shit happens

2 more bugs
i literarly found EVEN more bugs
i literarly have 1000000 bugs bro
and by found i mean encountered, idk where the issue is NOR do i know how to fix it
i want to cryyy in a cornerr
wtf...
and sometimes if i rerun the vm i dont get the page fault??/
wtf

:c
im afraid im gonna need some help with this
i am too scared to ask for anyones help with this cause i have fuckin done that too much
kinda stuck ig

Eat a 5 star
Is okie ๐ฅบ
My code has 99999999999999999 bugs 
my code has bugsยฒ
My code has :{:|:&};: bugs
I'm feeling like crashing my phone
maybe turning on ubsan might hlep
idk
im out of ideas
okay i turned on ubsan
its catching a few things related to pvclock
ima fix and see what changes
okay how is that out of bounds??
thats lit on the osdev wiki
and its deadlocking on uacpi with ubsan on?
changing it from 1 << 31 to 1 << 30 fixes it???
the deadlock for uacpi
and it still thinks theres pvclock
wtf
okay casting 1 << 31 and ecx into a u64 solves that
we still having the same issue and ubsan caught jackshit

@brisk zenith i know i ask help from you a lot but im like really really stuck with this, it would be helpful if you could take a look, apologies for the ping
1 will be parsed as an int, so it will be signed 32-bit integer. Shifting it left by 31 changes the sign, which may have triggered the ubsan.
makes sense
Were you to do 1u << 31 you wouldn't have this issue.
yea i did that, solved it
What's the thing you're debugging right now?
its a really complicated issue ill ping you to what im experiencing
I see. The mmap syscall is broken and crashes when interrupts get enabled, but deadlocks otherwise?
yep
Your master branch appears to contain an incorrect invokation of sprintf here: https://github.com/rayanmargham/NyauxKC/blob/69ebbb8bf2c0b215529328bd36e76b43b6dffd1c/kernel/src/arch/x86_64/syscalls/syscall.c#L45
Unless you have sprintf defined as something else?
Contribute to rayanmargham/NyauxKC development by creating an account on GitHub.
sprintf is just serial printf
I see
unfortunate naming
๐
no thats the thing, i hava no idea where it dies and the fact its rip 0 and it dies on instruction fetching a userspace program is something
https://github.com/rayanmargham/NyauxKC also @broken depot you should look at master branch
Is it consistent enough you could re-run and debug until it crashes?
also ive tried to figure out why it dies but i literarly cannot find it 
RIP becoming 0 can mean one of a couple things:
- Return address corrupted into 0
- Noreturn function does return
- Null function pointer called
I would suspect that last one first
if it was a null function pointer with the vfs
that would happen on kernel land
i dont use function pointers anywhere else
as for noreturn function, i usually have panics on functions that arent supposed to return
It's userland that goes RIP=0?
yep
page fault is error 0x14
instruction fetch on userspace
ok
maybe you didnt switched cr3 ?
i do???
what its trying to do
that lit cannot happen
read above
i dont finding qemu log
what
do you post your qemu log
i dont need the qemu log for this as my idt catches the exception??
Presumably userspace gets RIP=0 immediately after the syscall drops back to ring 3? Wouldn't that suggest that either something corrupted the syscall return address to 0 or that you restore it wrongly?
I'm looking at your syscalls.asm for x86_64 rn
could be? but it should be restored i believe
I cannot immediately see any problem in that file.
yea i lit dont know
And this relatively directly calls syscall_mmap
pretty much
How large is the stack this runs on? Is there any possibility there's an undetected stack overflow?
the stack is quite big
#define KSTACKSIZE 16384
#define USTACKSIZE 1048576
thats the stack
sizes
That won't overflow like this
can you say what is the problem, maybe i can help
Do you know the mmap parameters that cause the crash?
read above i explain the issue above
ok
i believe so
ill check for ya
syscall_mmap(): size 602112 flags 32
Page Fault! CR2 0x0
RIP is 0x0. Error Code 0x14
flags in hex btw
Hint nonnull? Or null?
ill print hint hold on
wait you enabling interrupts on syscall???
yes?
syscall_mmap(): size 4096 flags 32, hint 0x41600000
syscall_mmap(): size 90112 flags 32, hint 0x41601000
syscall_mmap(): size 847872 flags 32, hint 0x41617000
again its kinda inconsistent
but there is hint
inconsisent meaning it will either do the page fault or deadlock or work
usually page fault
That should be fine as long as the syscall stack is dedicated to it and either no preemption or it's set up as a proper thread. BadgerOS does it in this last way.
i always disabling interrupts in syscalls and in interrupts handlers
(uint32_t)1 << 31?
because it SEEMS like some thread x is holding the mem lock and then thread y calls the fuckin memmap syscall and it deadlocks on that
so i need preemption on syscalls
Certain code can't safely run with interrupts disabled actually. That's the case for a lot of internal things in my kernel because it's made to be preempted basically everywhere.
what if other process use syscall when other process already in syscall on same cpu
ik
do you changing stacks ?
should run fine?
they are different stacks
i realized
Just use a separate stack. I always pair a kernel stack to a userland thread for this reason.
Anyway, back on topic, hint is nonnull
yep
I'm curious as to why this slabfree is here: https://github.com/rayanmargham/NyauxKC/blob/master/kernel/src/mem/vmm.c#L228
the vmm region structure is allocated with the slab allocator
i mean do you have per process syscall stack ?
-# that would make your asnwer "no"
If you are able, maybe you should print the stuff that gets used by syscall for return address when running mmap?
wdym by this
At enter and also just before returning.
Print what the syscall return address is
Both when just entering syscall_mmap and just before returning.
id rather not cause that means i need to fuckin do some weird ass shit
im too braindead
Well, rcx gets stored at an offset of from the value of [gs:8], which would be your kernel syscall stack top.
So that would be *(uint64_t*)(stack_top_here - 3*8)
ill try that
try to print rcx when leaving from syscall
maybe its zeroing ?
ill see hold on
That would be the address I just told him to read
^
Literally what I was figuring out the pointer to.
looks fine
i print on entry and exit of syscall
then syscall is not cooked
Error code still 0x14?
yep
So IRQ 14 (decimal), error code 20 (decimal)
yes
SDM agrees that this is user instruction fetch
yep ik
maybe user stack is overcooked ???
I'm not super familiar with x86 so I wanted to check
makes sense
wha
Check that your user stack is correct. If that stack pointer got moved somewhere that made the return address 0, you could see this fault.
i can print that on mmap ig
@broken depot yea okay
something cooks the user stack ptr
bro how does your kernel even run ๐
wdym
That is the same at enter and exit, which implies it's actually something else that causes the thing at the last mmap
yea
??
bro is not explaining
Because how can this be a valid user stack pointer? I think that something is going wrong in a context switch somewhere.
bugs, bugs everywhere
true
Be that syscall enter/exit or thread switch, this cannot be correct.
yea
Perhaps check you disable interrupts before you get here: https://github.com/rayanmargham/NyauxKC/blob/master/kernel/src/arch/x86_64/syscalls/syscalls.asm#L93
i can attempt to disable interrupts there
doesnt solve it
same issue

Does this thread yield or get preempted between these two mmap calls?
id assume so
I think now would be about time to get the debugger to figure out what corrupts the stack pointer.
fun
Can't right now sorry, busy playing through deltarune
BASED???
DELTARUNE IS FUCKING BASED
yooo monkuous have fun
Thanks
Accidentally lost my save some time over the last few years so I have to play through the whole game again
that makes sense lol
I mean it's a Toby fox game I'm sure I'll love them
you will
I SAW THAT STAR INFY, DELTARUNE PLAYER TOO?
not my thing
fair
i like games with graphics 
@broken depot
so something happens and the rsp is swapped with syscall_stack_ptr_tmp
thats fucking weird as shit
oh
@broken depot I FIXED THE PAGE FAULT ISSUE!!!!
nvm
@surreal path btw u know u can debug from vscode directly right
ik
but im too lazy to set that shit up
a made a script to autogenerate vscode configs for that for my kernel
works pretty well
where can i find it
im gonna implement idt and gdt in my kernel now, should I add gdt.. ok and idt.. ok @surreal path ?
bro did not see the nvm
yes 

Yes 
slient gdt init...ok

Write the string "gdt init... ok" to a random memory address 
maybe i should detect avx512 support and then that would enable verbose gdt
and you dont ask me, the biggest gdt ok idt ok connoisseur... I know the real ones
okay i feel like its in relation to syscall stack tmp and syscall user sp
but doing what i should do breaks mlibc (which means my kernel is broken)
i dont know what im supposed to do in the actual scheduler itself with syscall stack tmp and syscall user sp
do i just leave them
idk
okay
i think i have a general idea whats happening
because i enable interrupts for the syscalls, at the start of the syscall i throw the user rsp into syscall_stack_ptr_tmp and load kernel_stack_ptr from gs then before sysret i load from syscall_stack_ptr_tmp into rsp
now what is probs happening is that on preemption i save the context, but that saves the user context not wherever the syscall is, sched yield works because it manually builds its own stackframe. so basically when preemption happens i go to another thread and whenever i switch back to the thread i load the USER stack and rip, now the user thread assumes the syscall went well and just dies
how to fix this idrk
@brisk zenith im assuming this is kinda correct?
idk enough about your kernel design to say
right
if that is indeed what's happening then it'd definitely cause issues
idk
fair
sorry for the short responses im busy fighting jevil
spam the act pirroute if your trying to beat him peacefully
its op
and dont apologise lol glad ur having fun
if not, just defend for rude buster and spam rude buster
this is where im at rn, just finished the giant fullscreen attack
not looking too good item wise
no this is on linux with proton
okay so defend, rude buster and heal prayer susie
yea good
well then
you made a program to keep track of this?
yeah my inventory is full of them
okay
use them sparringly
during the fight
you wanna take advantage of ralseis heal prayer
if your like <20hp then yea def heal with an item
wait no this shouldnt happen???? because its happening via an interrupt??? wtf
idk anymore

time to cry in a cornerrr
u mean lock in
no 
yes
try to imagine what u would do if u were monkuous
im not monkuous i cant imagine what goes in their head lol
try really hard
all i can think of is printing the rip and rsp of a frame every preempation
but thats not because i imagined i am monkuous
i lit just came up with that rn
good start
ill also print syscall tmp ptr
in mmap
rip and rsp looks sane
try different opt levels as well maybe?
Higher opt levels can make debugger info worse and are also likelier to make optimizations that would break with ub
maybe hes already doing o2 or smth
im already using o2
All I know is that I go to -O0 anytime I get a heisenbug
now try that on linux 
Pain
-O0 Linux kernel sounds slow as mollasses
nah it just wont compile
That is very surprising
idk, tech debt
Are they relying on different behaviours of I suppose specifically GCC on -O2
hard to say because it doesnt even compile because stuff doesnt get optimized out
but it probably wont boot
99%
Ahhhh
the addr are always the same but sometimes ptrtmp doesnt print
Not optimized out -> uses some functions that are compiler built-ins?
see some examples in the so question
ill turn on O0
pretty much
wait wtf were u using
That implies the MMAP isn't always anon? Otherwise UB.
O2
bruh
no i handle that, if it isnt anon i enosys that shit
bro is debugging with O2 
but even with O0 some values still get optimized out
Og
if u ignore the preemption taking shit it seems to be that syscall user tmp gets changed on the same thread
by something
i use O0 and -g
bptrtmp 0xfcf10 t 3
and then
ptrtmp 0x100a48 t 3
Set a watch point at the address of syscall user tmp
-ggdb3 for most debug info
what does that do
will do
never seen this flag
adds debug info
works with clang too?
I knew of -ggdb but there's even higher tiers of it?
yeah lol
it made it a hw watchpoint?
should work ig
like what
this aint kvm
GDB thinks it's hardware because QEMU reports it as such
idk but makes debugging pleasant
i also finally managed to start debugging with CLion
More accurate tracking of register <-> variable mappings for the most part AFAIK
and it's gdb integration is SO GOOD
how did u set that up
with qemu
i found some old extension but it didnt work
no extension needed
don't mind the mappings
they are not needed for me
they are a leftover from windows
i had a ton of trouble trying to use it from wsl tho
its not an address its a value so i need to watch the cpu
but native linux works very well
oh so its native linux
and u have to run qemu manually right
yes
i have a more automated thng with vscode
how?
ig, sucks that this only works on naitve linux
using before launch
nope its inconsisent
sometimes that doesnt happen
couldnt make it work on wsl
it theoretically could work on wsl too
maybe it was bc i had gef installed
strange because it should be the exact same speed
and basically instant with cmake config and compilation
it is def way faster
still on O0
can run the whole os till scheduler start in less than 1s
I usually recognize people by pfp and I was extremely confused who this random person monopolizing the nyaux thread and then I realized 
- i got at least double the speed of uacpi loading
whos monopolizing
huh
me confusion
crazy
I thought you were a random person taking over your own thread
lmao
oh XDD
I didnโt recognize you because you changed you pfp ๐ญ
yes
we lock in
agree
Anyway
imagine using the nyaux thread to debug nyaux
๐ฑ

anyway, good resources on ipc?
Iโm a little slow sometimes
fast memcpy
?
WTF
= good ipc
yeah i have a "fast" memcpy
even for user copies?
its this values before preemption
for user i'll use libc one
i mean copy_from_user
with xmm and other improvements
it fucking changed
huuh, what
how do u access user pointers in your kernel
my kernel is trolling me
idk why its changing

like the only time i touch it is fork()
i still have not user mode yet, but each process has it's own context
so just load the context
ill print before fork happens cause i didnt get a fork log
something has the wrong pointer maybe?
and is overwriting data
no idea
u basically need a memcpy that can return an error if it page faulted during the copy so u can return -EFAULT back to user
rn i have a bigger issue
fork goes fine???
the stupid kvm clock resets itself
ghosts hunted your kernel
rn tho, i want ipc only for kernel threads
for drivers
is fast memcpy the fancy compiler intrinsic memcpy
no, it's either rep movsb, memcpy optimised for certain sizes and alignments, sse
or why not all of them
rep vmovdqu16
compiler intrinsic just calls into your memcpy
oh... ๐ฅ
and can you ask him specifically this: "can you send an iso of your os with doom included so my buddy can beat episode 1 while using the same computer to heat water for his tea?"
@linuxmaster2.0
@surreal path
Damn when can he expect a working iso
when its fixed
i will send when its fixed
Aight cool 
we ball at 5 or smt
little tired
im gonna try to watchpoint the fucking syscall ptr tmp like @mossy belfry said
if that doesnt work
out of ideas again
good luck ๐ฅ
thanks
yo mb
its just a bit too hot
im just waiting for the temp to cool
its really hot today

average day in the southern us
okay bro
good luck on the weather
execution date today
it's 31 Celsius where I live
35 here
12C
wow
22 Centigrade for me
Centigrade sounds cooler to me lol
It was 3ยฐC in the morning today, you can take some cold
okay so i tried the watchpoint on the syscall user tmp
var
no luck, gdb catches nothing

guess we gotta wait for monkuous i suppose?
fucking hell bro

yea i am lit desperate
fucking nothing

i just want this solved
there has to be SOMETHING im missing
do you know where it suddenly changes
mmap
i have an idea, you can break it right before that and manually step step step and print it out until it changes
did it not show up ๐
doesnt help
so u were able to catch the change tho right
im even on O0 as @kind root suggested
it happens on mmap after forking a process and attempting to mmap shit for the dynamic linker
is monokous able to run your kernel too or do i just have to stare at code lol
i'll try to run it ๐ฅ
mood.
ok i think the building is going well ๐ง
real
Creating config file /etc/mercurial/hgrc.d/hgext.rc with new version
/jinx: line 656: cd: /base_dir/base-files: No such file or directory
make[1]: *** [GNUmakefile:13: nyaux.iso] Error 1
make[1]: Leaving directory '/home/gummi/NyauxKC'
make: *** [GNUmakefile:10: all] Error 2
make: Leaving directory '/home/gummi/NyauxKC'
๐
uh oh
maybe i will rm the git repo and try again
it's compiling just fine
rayan your build system takes a little while
is this why the build dir was 20gb or something
very many time
LOL WHAT
idk man i managed to write 3 unit tests, eat dinner, and build nodejs and nyaux still isnt done
"build nodejs" isn't a joke here, gentoo decided to update it today
XD
its called having a build system
linux kernel scheduler was probably in a bad mood today, it's ok
wtf are u one abt lol
it didnt feel like running the build system
thats normal for any build system
what is it actually building tho, is it just making sure that your environment == my environment so we dont have "Works on my machine!" scenarios
hmmm
i shall fix diz
@surreal path btw you should write Co-authored-by: username in your commit messages if you want to give attribution
It will even display monkuous pfp and stuff next to the commit
ah i see
is this supposed to do this
rm -rf subprojects/uacpi
same issue
yea i def should next time they help
can u just
ok it worked now
i did do that
i did that already and it took 40 minutes to rebuild your project
i dont really feel like waiting that long again and i already built sysroot
u gave up that was ur fault but ok wtv
your build script is broken, the first time i compiled it i just ran make in sysroot and it created that error
i think you forgot to include uacpi as a submodule or something
i ran make in sysroot
tell me the error
that was the error
i have a very long list of build output commands one sec
see here it says it took 38 minutes
see dms
last resort chat
im just gonna ask the osdev forums
and if we get no help there
idk

Letsgo
huh whats with asking the osdev forums being good
Lol idk
It has some experienced people
i think i have to open a DE now ๐ข
it ok tho
12 second boot nice
now how do i make the bug happen
In total there are 3110 users online :: 10 registered, 0 hidden and 3100 guests (based on users active over the past 5 minutes)
run any program that forks
did it happen
ai scrapers are eating the forum rn
what???
run it again
are those the ones that ignore robots.txt?
so basically all of them?
the devs of claude are the worst ones
but you can use cloudflare to filter them out i think
25gb build dir, nice
thats fine
?
wdym by ?
wdym what you gonna do?
i mean what i said, i literally dont know how to solve this issue.
i dont know what to do going forward
is the forum down?
no its just mostly bots now
what?
maybe it can help a bit
it is very good at finding issues
????
well, your problem is probably caused by an issue in your os code no?
yes
maybe the AI can find it
I find that unlikely lol
well, researchers used it to find some important bugs
so not all hope is lost
look it up
๐คทโโ๏ธ

just ai models and people saying NOT to use O2-O3 when debugging

at first when I heard O3 I thought he was talking about the optimization flag XD
oh XD
one out of the million made up instances or false positives, congrats
^
well, ofc
just please stop suggesting LLMs for this
but it might help
don't defer your critical thinking to clankers
it does, for speedrunning atrophying your brain
congrats you won the leo prize for shit quote of the day
it probably won't
the problem is more that the bots are slowing the forum down a ton
oh i see
the bots are only reading (since they're guests anyway)
299 Kelvin where im at rn
Eyy!
I tried to use an llm for programming and I started to just wait for autocompletions instead of actually thinking
I removed it after I realised that
shit like GH Copilot is good for autocompleting memcpy and appending comments when closing C++ย namespaces
for the rest have fun
it can be useful for doing stuff like asking what does linux's function x_y_z() do` tho
i dont need copilot check out how incredibly useful my autocomplete is, you can find the function you need in only around 2-3 business days
(no idea why this happens)
hello
i have just waken up
give like a few hours and we will post onto the forum
wait qwinci why can user tmp change, who changes it???
i am reading old messages as to figure out why some parts of my code do this
maybe this could be our issue?
oh god no please
why?
it's just a bunch of boomers
don't
if i were u i'd rather spend an eternity trying to debug it myself than ask the forums
probably
i guess we will wait on qwincis response here
judging by the quality of most posts i've seen
maybe memory leak ?
what? no? tf u on about lol
Memory leaks don't lead to memory corruptions
i mean
maybe
you memcpying
and idk how changing this value ?
also considering my allocator is pretty battle tested (thats not to say its perfect or wont lead to isssues in the future, heck even managarm had slab corruption issues) i wouldnt blame it
bro we know something is changing the value
we just dont know why
i lit did
ah
oh oh
I don't exactly remember and can't take a look at the code properly rn as I haven't yet unpacked my pc after moving yesterday (its also the reason why I haven't been that active lately)
but managarm had 10 years to write and test their stuff
and u haven't
ik
im not saying its good
im just saying its probs not the allocator for this situation
ah okay, when are u fully moving in?
i mean prove me wrong lol, if it is ill eat my words up
hm?
I mean I've only asked the forums stuff like, twice before, but it doesn't seem that bad
they're all old
okay interesting
commenting out these lines in waitpid causes the same fault
i genuinely do not know why
i did this before
yea doing what waitpid does
in mmap
does NOT solve the issue lol
i thought

back to dying
yea i have no choice but to ask the forum
worth a shot
post made
hopefully one smart boomer will respond

extreme measures
very much so
the more extreme measures is rubber duck debugging
okay so
theory on why this didnt work
id imagine that when mmap got preempted, some other thread made a syscall while interrupts were enabled
and that piece of code which i still do not know why i do doesnt execute cause its only on mmap so
that probs is what happened
i mean plasubile
what ill do is add those 2 lines in every syscall, along with disabling and enabling interrupts beforehand
if that doesnt work well fuck all
im genuinely just throwing shitty idea after shitty idea
just to get something to work lol
idc tho ill never give up with nyaux
even if we dont get help
even if we are stuck for years on this
idfk
did you log interrupts
nyaux is my child
ofc
lol
did i just...
solve my page fault issue...
i added cli to the start of the syscall asm
i wanna make sure this is real
i have solved it...
I HAVE SOLVED THE PAGE FAULT ISSUE
yea it still deadlocks on the mem lock BUTTTT
PROGRESSS
@kind root banger right?
if i enable interrupts on every other syscall and do the same shit
it might work
and not deadlock
hope is hope bro
and why it deadlocks now
keyboard interrupt wants to allocate memory for the keyboard packet,
Well then interrupts aren't enabled during syscalls, wasn't that the point?
the userspace thread is holding the mem lock
no, during a syscall function that can be preempted now
the syscall asm cannot
but the syscall function itself can now
Ah
^
okay we are closer
i made the memlock disable interrupts then lock then unlock then enable interrupts
seems like forking any program causes some weird ass shit
which is better?
idk
this is how it should be
yea
otherwise there is a race condition for deadlock
pretty much
yeah just make it so its disabled on entry always
theres a flag for that no?
whats ur opinion on us getting closer to fixing all these issues tho?
i believe so
also it seems like sys openat is getting preempted even tho it shouldnt
i think i know why
i dont check if interrupts were enabled in the first place for the mem lock
and just enable them
vfs lookup does some allocation so
yea
lol
makes a lot of ze sense
i would fix if VSCODE WASNT A PIECE OF FUCKING SHIT
did arch break it???
it wont launch after i updated it


linux user
okay bro




