#Nyaux
1 messages · Page 53 of 1
ok come on bro
i think i need to recompile nano to
too
same issue on nano
@molten grotto
LOOK NANO WORKS
LETS FUCKING GOO



3 weeks ago u worked on it
im considering switching back to mints branch atp
if ur not gonna mantain it
😡
Why was it forked in the first place?
sixel support
(I'm still using 1 year old version and it works fine
)
that's not much information about the issue you're having, is it?
im not having an issue
rn
what do you want fixed then mr
mantain it lmao
theres some bug with sixel
no
thats crazy
as I said, it was just an experiment

https://www.reddit.com/r/osdev/comments/1julxdf/nyaux_runs_nano/ 100 upvotes pls thanks

nice
Damn well done
thanks bro#
time to debug why nano is using canoical mode??
Just port vim instead 
thats even worse to port
😭
that's normal
Bro how the fuck did your shit get 7 upvotes but some idiot with nothing but a kernel toy shell that is 2 c files get 300.
how so
instead of "debugging" why it uses a properly supported feature you should implement it
i did
tho
good
because you implemented it incorrectly probably
and moves the cursor down
no but shouldnt nano be using raw mode
first off
and second off
no idea lmao
no not really? its literarly just a few lines of code
if (tty->termi.c_lflag & ICANON) {
for (; i < (int)size; i++) {
uint64_t val = 0;
get_ringbuf(tty->rx, (uint64_t *)&val);
((char *)buffer)[i] = (char)val;
if ((char)val == '\n') {
break;
}
}
return i;
}
its just this
No, it should be
otherwise i will do this
i don't think that's correct brother
or Maybe it is
who knows
not me!
I love spreading misinformation :3
bru
Shit I’m stupid I misread your message
?
You said “shouldn’t nano be in raw mode” and I read it as “nano shouldn’t be in raw mode”
It's like when Managarm systemd was anounced, a lot of people were asking "why"
Those dumbasses probably don’t know the difference between ring 0 and ring 3
Because it's been like an hour lol
do i need fcnctl for nano input?
i might be wrong idk
im just reading nano source code and trying to make sense of it
Ironclad reference?!
i cant even get raw mode or cannoical mode working

i dont fucking understand why giving it one character doesnt make it happy for raw mode
but wtv
cooked
what
it's called cooked mode
man page says cannoical
man page is cringe
posix says canonical as well
i saw that, i hate that so much
Btw why is it called cooked, I still don't know to this day lol
cooking transforms stuff
the raw input and output is cooked into a nicer form
because the other mode is the raw mode
Makes sense
They really have been cooking with this rare w name choice
i cant get cannoical or raw mode right for userspace to accept it 
possibly the only way im gonna understand how raw mode vs cannoical mode works is probaly gonna be me writing my own userspace program to test how exactly input works, then have this userspace program also in my userspace for nyaux and compare it to linux and adjust tty code til i get it as close as possible to the results of linux
tmrw i get my weight loss pills (Glucomannan) so i can control my appetie cause recently ive been out of control and its been a major stress point for me
so hopefully tmrw im not as stressed as today
(i ate 3000 calories of chocolate AGAIN)
Okay man sounds good I hope you feel better
We love you man
Don’t ever rush the OS
thanks
you’re very talented and we care about your health brother
thank you :)
might be helpful
ive read this
😭
blame the article for not bothering on explaining implementation side of things
and just pointing me to fucking linux source code
yea thats fun
:^)
Which may or may not be readable depending on the mood torvalds was in when he allowed the commit to be pushed lol
real
the good thing is that you don't need everything
just newline conversion, EOF, EOL, erase, echo, echoe and signals is enough for nearly everything
new line conversion?
yeah 😭
what is that?
why exactly do i need to do that?
i see
cuz in raw mode enter sends '\r' counterintuitively
and what sends \n in raw mode?
never knew that but ok lol
yeah i only figured it out when implementing my vt
in raw mode does every character get printed by the program or by the vt itself?
echo is actually independent of canon but yeah
that makes sense cause the quick test program i wrote still prints characters, even in non canon mode
i see
wtf?
How does that even happen
i dissabled optimiztiations and its still doing this
(at some point my kernel wasn't working without optimizations)
lmao
im gonna cry in a corner
did you push this?
on github?
yeah
@flat nymph sorry for leaving
me when base 10: 

i fell asleep
Hi Rayan 🫂 💙
your punishment for that insolence will be more nyaux work!
how could one even sleep, unimaginable. 
this issue seems more complex then the getcwd problem
time to put printfs all over nano source code
i know im joking
(thought it was obvious with the rage face lmao)
bagel ur morning
also have i never spoken before in this thread wtf
And then the whole diagram of a pipe thing happened 
Wait, how do you search within a thread?
infitely allocating here
I didn't
I had to find messages in the progress report thread channel which shows messages from all threads
while (true) {} is UB?
Yeah but no compiler would actually optimize it out when it's so explicit, that would break a lot of programs
yes
i think the program that breaks expectations looks like this
#include<stdio.h>
int main() {
while(1);
}
void what() {
printf("what???");
}
nano is infintely crying here
infitely allocating here it seems
which makes sense?
senes*
senes
senses*
BRO I CANNOT SPELL 😭
back to the ncurses dungeons 
not since c11 afaik and there was a defect report in c++ to make it non-ub as well (though clang was the only compiler that fully optimized the loop away and caused weird stuff, since like clang 18 or smth it doesn't do that anymore to comply)
i swear to fucking god if i am being gaslighted
gaslighted by the c compiler

richard stallman laughing with his beard
?
it was a "bug" in clang that has been fixed recently
it used to be
how this is possible im unsure
ncurses code looks like shit as usual
so
in C++
back to trying to understand ncurses code for like 50 hours lmao
#ihategnustylecode
I believe it's still UB in C
#gnudevelopersshouldbepolitelysenttocastledungeons
I remember reading a proposal for C++ to define that loop
its either gnu code is too big brain for me to understand
or its too shit for me to read
can someone tell me why all gnu software code is like this
genuinely
i should make a gnu code style bingo card
- shit indentation
- macros everywhere
I don't think its ub after c11
The forward progress guarantees were added to C++11 and C11 along with a memory model.
true
it was a C++ proposal and I assumed it only applied to C++ lol
that proposal also says C does not make iteration statements whose controlling expression is a constant expression Undefined Behavior, whereas C++ does. so I don't think it was a thing the compiler was allowed to do before either
but anyway
does ncurses expects read to return an error of some kind?
tw event?
tf
tf is key min
yea i know this is whats making it infinitely allocate
it thinks it doesnt have enough space for some fucking reason
idfk how to tell nano to stop
or rather ncurses to return ERR here

i hate ncurses i hate ncurses i hate ncurses
@broken depot u must agree
ncurses suck to deal with
yes it does
and i have no idea why ncurses is not happy

arbitrary reasons
its not fun reading ncurses code
its not fun debugging ncurses
its not fun ncurses in general
why do we use ncurses
why cant programs just fucking implement their own shit for the tty
it isnt that hard, oooooo tcsetattr() so scary
@unkempt relic i know u havent been in this thread for a long time but i wanted to show u this cause of the good progress we've been making on nyaux
also i hope keyronex is going well
let me peep into the thread actually
i've been watching with considerable interest
nyaux is progressing remarkably well
taking a break today cause im too frustrated with ncurses
as per usual
now i shall sleep
thank you!
Yeah Nyaux progress recently is absolutely legendary
Yes
When I start my os i probably won't reach nyaux levels until like a year into the project or even later 
me when i see chocolate egg
is oki u will get there 
also opinion on chocolate egg
make uacpi users to sign a contract requiring them to contribute to your os as a payment

i feel so poop today :c
okay so
this condition never happens
oh yeah
now that we are past userspace
i should make a wishlist for any contributors looking for work 🥺
what i really want rn is someone to at least EXPLAIN what the code does so people understand what they are looking at instead of going wtf is that in there mind
so basically comment everywhere in code lol
documentation basically
we also have some weird amd bug @tender gorge reported on
who needs to make a github issue 🥺
🥺 🙏
maybe fix my non existent clang-format file so everything looks readable at least
idfk i should probs do that myself but its not main priorty atm
and im not expecting any contributors
to be fair 😭 💀
also i said id be taking on break on nyaux for today cause ncurses, well turns out i lied lol
okay so
real
we need to figure out why input doesnt return ERR
so to do that, we need to determine how ERR is decided to be returned by ncurses
this is the source of our problem
this is never true @molten grotto is this bad? because nano depends on ncurses to return error on wgetch() for it to stop reading keycodes
maybe, idk

ncurses gets 0 in raw mode, after reading the tty which is in raw mode
is this not allowed
does this break abi
okay i see
i keep forgoring 🥺
is oki 🥺
Can I rewrite your context switching code? 
go ahead
as long as it doesnt break stuff
Ok, I'll look into it tomorrow
issue now with bash :) it doesnt print the character until u press backspace
static size_t rw(struct vnode *curvnode, void *data, size_t offset, size_t size,
void *buffer, int rw) {
if (rw == 0) {
struct tty *tty = data;
// TODO check non blocking
if (tty->termi.c_lflag & ICANON) {
int i = 0;
for (; i < (int)size; i++) {
restart:
uint64_t val = 0;
spinlock_lock(&tty->rxlock);
int res = get_ringbuf(tty->rx, (uint64_t *)&val);
if (res == 0) {
spinlock_unlock(&tty->rxlock);
sched_yield();
goto restart;
}
((char *)buffer)[i] = (char)val;
spinlock_unlock(&tty->rxlock);
if ((char)val == '\n') {
break;
}
}
if (tty->termi.c_lflag & ECHO) {
flanterm_write(get_fctx(), buffer, size);
}
return i;
}
// return a character
int ok = size < VMIN ? size : VMIN;
int i = 0;
for (; i < (int)ok; i++) {
restart1:
uint64_t val = 0;
spinlock_lock(&tty->rxlock);
int res = get_ringbuf(tty->rx, (uint64_t *)&val);
if (res == 0) {
spinlock_unlock(&tty->rxlock);
sched_yield();
goto restart1;
}
((char *)buffer)[i] = (char)val;
spinlock_unlock(&tty->rxlock);
}
if (tty->termi.c_lflag & ECHO) {
flanterm_write(get_fctx(), buffer, size);
}
return i;
} else {
// MOST BASIC AH TTY
flanterm_write(get_fctx(), buffer, size);
sprintf_write(buffer, size);
return offset + size;
}
}
source
@elder shoal is this something to do with fflush()
?
page fault when pressing a keycode in nano but one problem at a time
fflush is libc stuff
okay
I think it should print immediately if you're writing to terminal, and otherwise untill you press the backspace?
what
i will work on nyaux maybe tmrw idk i feel like poo
nvm
ill work on it
now no 1
why isnt bash printing my fucking characters
@molten grotto what would be the first place to check if bash is deciding not to print my characters but only if i backspace them
what did you change that made it not work
made read blocking
int ok = size < VMIN ? size : VMIN;
int i = 0;
for (; i < (int)ok; i++) {
restart1:
uint64_t val = 0;
spinlock_lock(&tty->rxlock);
int res = get_ringbuf(tty->rx, (uint64_t *)&val);
if (res == 0) {
spinlock_unlock(&tty->rxlock);
sched_yield();
goto restart1;
}
((char *)buffer)[i] = (char)val;
spinlock_unlock(&tty->rxlock);
}
if (tty->termi.c_lflag & ECHO) {
flanterm_write(get_fctx(), buffer, size);
}
return i;
as u can see
this is if im in raw mode
which i am
with bash
@molten grotto
nvm i know the issue
I don't think bash uses raw mode
it does
actually wait yeah, I were thinking of the wrong thing lol
should i keep of list open file descriptors to said vnode inside a vnode or just add another arugment to my read() for fd options
?
for what flags
fd flags
like non blocking etc?
yea
I'd probably just have an argument for them in the op functions
because open files aren't really tightly coupled to vnodes
this thing is so big
you could move the options to a struct
why aren't these separate?
like separate read and write members
idk
btw I were looking into making mlibc glibc compat work with newer mlibc and it doesn't look good 💀 the major pain is symbol versioning that got implemented in mlibc and it means that apps linked against glibc no longer even get linked by the rtld because of mlibc not having the same versioned symbols as glibc
no 
dies
I think the easiest solution to this is to write a tool that strips versioning information from the binary linked against glibc but the annoying thing is that then I can't test this stuff on linux at all because of all the other libs and whatever linked against glibc also having versioning info (and I don't want to start modifying system libraries)
i need help
, nothing fixed this
bash did not supply nonblocking
for the tty bash does supply the nonblocking flag when opening, it's also shown in the image that you sent where the flags in decimal are 2050
no it doesnt
it only supplys 2050
and that includes the flag
how
its in octal????
yes its what the zero prefix does
but i & it with the file descriptor flags
and it isnt non blocking cause it didnt go through
when I tried it it went inside the canon if and didn't enter the blocking loop
doesnt print
what
thats weird af
I can try again after I get back home in a bit but iirc
please do when u get home
cause im hella lost as to why this isnt working lol
@molten grotto u home?
yes
alright, try and see what bash is doing on ur machine
im sure its the same result
ah I didn't have rebuilt mlibc, after your dup2 impl it looks like that thing happens where bash doesn't display the chars
yea :c
i dont know why :c
try to have a look if u can cause im stuck 
oh yeah @molten grotto returning enosys in dup2 doesnt fix ze issue either
thats interesting flags is 0
yea weird

:c
@molten grotto so i know that stdin flags are 0 because i always setup stdin per process, and i initally set stdin to flags 0 but why doesnt bash do something like fcntl the fd so its not blocking. does it expect to be non blocking on boot up??
is that what bash expects as the default?
I think I found the problem
What is it
the termios c_cc has the fields VTIME and VMIN, there are various cases that do different things but if both of those are zero then you are supposed to do a non blocking read
Where in the man page does it say that?
I see
where is this btw
im gonna add the check and see if this solves it
yea that solved the bash issue
time to test nano
again
nano is still expecting read to be blocking (or well ncurses) even tho vmin is 0 and vtime is 0 and flags is 0???
fucking hell ncurses
wtf ncurses like bro
what do u want
Does ncurses actually want vmin and vtime to be 0?
idk its set as 0
That's what I'd figure out next
something to look into ¯_(ツ)_/¯
if i set vtime to 5 initially bash is no longer happy and does the same bug again
whats up with that?
idk tbh
interestingly vtime is never set in managarm
maybe theres a reason ?

im cooked
ill ask korona or smt maybe when hes back in vc about this cause im just 
ill do further debugging in a bit as to WHY ncurses expects a blocking read
apologises for the slow nyaux development
bug after bug really gets annoying
especially when ur trying to port nano
which is a bitch to port
especially with tty bugs which are the most annoying ill admit
id rather fucking debugging rip 0x0 bugs then this shit
im not gonna have fun implementing signals after this
thats for sure
i contributed to mlibc today so that was nice
https://github.com/managarm/mlibc/pull/1348 my pr btw :3
first mlibc pr that isnt sysdeps
@alpine mulch ur next
ur ec driver is next :)
im gonna watch some ada tutorials or smthin
or just write a basici userspace ada program
idfk
also i should update uacpi
i hope the api hasnt changed
@kind root me being absolutely clueness fr
(i havent updated in months)
api has been stable after 1.0
really now?
I know, crazy
crazy indeed
okay i see
have there been any news about ROS and Haiku?
ROS is WIP
Many conversations happened during CLT2025 but one that stuck with me was the more indepth talk about breaking up what i do further. This is my attempt at making good on this conversation.
This PR ...
The guy from haiku just disappeared so no idea whats happening there
i am the stupidest
stupidest
bro
i was returning read 1 byte even tho i read 0 bytes
💀
yea bash exits from that, like bro what am i supposed to say
fuck i fell asleep
Happens sometimes over there

i dont fucking know how this read keys from function in nano works
:c
atp i dont know how to go forward
lemme try to sleep now
so i can be awake when qwinci is online
and actually ask
Goodnight 💙
i fell asleep again :(
Wasn't that your goal?
Something about differing timezones
im sorry im having really bad days atm
no development or debugging until tmre
even tmrw is a maybe
i had an awful day.
Take your time. Don't force yourself to work on this if you don't want to. Also, I hope you feel better soon.
@surreal path how do you even make deltarune last that long
content runs out
or do you just play again but different paths
stuck on spamton neo
thanks
i might work today
or tmrw depending
on my mood
im ready to do nyaux development today
lets start by asking ourselves how we can solve this issue
to which my answer is no idea

@molten grotto have u reached a point where u ported ncurses before
like at all
not really

do you still have the same weird tty problem
yes
ttys kinda suck ngl
if vtime is set on tty init to 5, bash isnt happy and does that character bug again. if vtime is 0, ncurses isnt happy and nano infinitely allocates a keyboard buffer because wgetch never returns error cause ncurses was expecting a blocking read
even if i default everything to a blocking read it still dies
and i have no fucking idea why its doing this
i read the openat flags and i set them and i check them
and i do the weird ass thingy if vtime and vmin are 0
WHICH THEY ARE
and ncurses STILL expects a blocking read like bro
and btw @molten grotto ncurses never calls fcntl or that shit so it never even tries to change the flags of the fd so i dont know where its pulling out its ass that its expecting a blocking read*
vtime and vmin are still 0 so read does polling and ncurses wants blocking
yea i remember
even tho it never changes it
I think I had ncurses
and bash worked fine
I don't know about nano
you can check the tty implementation on the old branch on my repo
yea not until u actually RUN ncurses, which means running nano
bash is compiled with ncurses
thats not gonna solve it
yes and it uses ncurses dummy
it doesnt call wgetch
it does its own shit for input
you don't know that
that's not the whole of ncurses
ill look at it but i doubt anything ur doing im not doing
that where it dies in ncurses tho
hmm I remembered this file differently
i dont do that await shit but everything else i am doing
i dont understand the code very well tho as i dont read c++ so idk
either way i dont see anything helpful here
so you don't actually use vtime?
no
maybe fix that first
vtime is always 0
its never changed by bash OR ncurses
and typically that should be fine
is ioctl with tcsets never called?
my bootloader ignores vtime and it runs bash and nano with ncurses just fine
it is, but VTIME isnt changed
here's the tty code if you want to take a look at it https://github.com/monkuous/andromeda/blob/main/sources/andromeda-kernel/kernel/drv/console/console.c
code style is a bit unique because it's a cpu-local kernel stack so blocking uses continuations but still
how come eagain doesnt kill bash or ncurses for you
it kills bash and ncurses for me
that's the unique code style I was talking about
it returns eagain unconditionally, but if it's blocking the thread switches away before returning to userspace
and the continuation sets the actual return value
that's clever
yea i dont really see anything too obvious
other then vmin being set to 1 and u doing eagain
which is probs never returned

are you sure ncurses actually wants the non-blocking read? it never sets vmin to 0 for me
what's your default value for vmin?
5
wait, why 5?
i just did tcgetattr from one of my host's vts and copied the values returned
looks like managarm just sets it to the values from sys/ttydefaults.h by default
yea i believe cmin is 5
maybe it's this? https://github.com/rayanmargham/NyauxKC/blob/3f151fb6b875b801b250220acf912a30ed712121/kernel/src/dev/tty/tty.c#L26
you're comparing the size to the index of vmin, not its value
when i do make run-kvm i get this, do you know a workaround? ```
syscall_mmap(): size 524288 flags 20
General Protection Fault with error code 0x38
CR2 0x240028
-> Function: isr_stub_14.skipswapgs2() -- 0xffffffff800bfd31
-> Function: Unknown() -- 0x0
-> Function: Unknown() -- 0x0
NYAUX Panic! Reason:
fuck
oopsie uwu :3```
oh wait tcg works fine
that is very weird??????????????????????
huh??????????????????????????????????????????????????????????????????????????????????????????????
are u running amd
yeah
i think this might be the amd bug @tender gorge mentioned
:c so ur gonana have to sport tcg for now
that's fine
sorry i cannot debug that since im not on amd
i am very unfamiliar with jinx, what's the command to rebuild a package
./jinx regenerate package && ./jinx rebuild package
ah ty
np
@brisk zenith did u find anything
still looking
alright
rn i'm investigating why vmin and vtime get set to 0
because i don't observe that behavior on other systems
yes its quite weird
i was confused by that too
that really shouldnt been happening lol
thanks for helping btw
means a lot, especially with difficult issues like these 
if theres any way i can return the favour i will do so
right well i can say that readline at least tries to set vmin=1
still trying to find where it gets fucked

this is my favorite kind of debugging
lol
figured it out ```patch
diff --git a/kernel/src/dev/tty/tty.h b/kernel/src/dev/tty/tty.h
index 189857c..604d62b 100644
--- a/kernel/src/dev/tty/tty.h
+++ b/kernel/src/dev/tty/tty.h
@@ -121,6 +121,7 @@ struct termios {
tcflag_t c_oflag; /* output modes /
tcflag_t c_cflag; / control modes /
tcflag_t c_lflag; / local modes */
- cc_t c_line; /* don't know what this is but mlibc has it /
cc_t c_cc[NCCS]; / special characters */
speed_t ibaud; // input baud rate
speed_t obaud; // output baud rate```
kernel's termios definition didn't match libc's
no clue but it's there in the abi-bits struct
is nano running now???
fuck
well thanks for finding it!
what is the cc_t struct?
cc_t is just a typedef for unsigned char
so effectively whenever the kernel read from termi.c_cc[x] it got the value termi.c_cc[x - 1]
i see
oh btw this is also necessary for the vmin/vtime behavior to work correctly ```patch
+++ b/kernel/src/dev/tty/tty.c
@@ -33,8 +33,8 @@ static size_t rw(struct vnode *curvnode, void *data, size_t offset, size_t size,
int res = get_ringbuf(tty->rx, &val);
if (res == 0 &&
((hnd->flags & O_NONBLOCK) ||
-
(tty->termi.c_cc[VMIN] == 0 || tty->termi.c_cc[VTIME] == 0)) == false) {
-
(tty->termi.c_cc[VMIN] == 0 && tty->termi.c_cc[VTIME] == 0)) == false) { kprintf("blocking\r\n"); spinlock_unlock(&tty->rxlock); sched_yield(); goto restart1;```
could u give the patch header too
one second i'm trying to get rid of all the extra newlines added to files i didn't need to change
this is the full git diff output ```patch
diff --git a/kernel/src/dev/tty/tty.c b/kernel/src/dev/tty/tty.c
index e7a8029..f68617e 100644
--- a/kernel/src/dev/tty/tty.c
+++ b/kernel/src/dev/tty/tty.c
@@ -33,8 +33,8 @@ static size_t rw(struct vnode *curvnode, void *data, size_t offset, size_t size,
int res = get_ringbuf(tty->rx, &val);
if (res == 0 &&
((hnd->flags & O_NONBLOCK) ||
-
(tty->termi.c_cc[VMIN] == 0 || tty->termi.c_cc[VTIME] == 0)) == false) { -
kprintf("blocking\r\n");
-
(tty->termi.c_cc[VMIN] == 0 && tty->termi.c_cc[VTIME] == 0)) == false) { -
//kprintf("blocking\r\n"); spinlock_unlock(&tty->rxlock); sched_yield(); goto restart1;
diff --git a/kernel/src/dev/tty/tty.h b/kernel/src/dev/tty/tty.h
index 189857c..1538213 100644
--- a/kernel/src/dev/tty/tty.h
+++ b/kernel/src/dev/tty/tty.h
@@ -121,6 +121,7 @@ struct termios {
tcflag_t c_oflag; /* output modes /
tcflag_t c_cflag; / control modes /
tcflag_t c_lflag; / local modes */
- cc_t c_line; /* don't know what this is but mlibc has it /
cc_t c_cc[NCCS]; / special characters */
speed_t ibaud; // input baud rate
speed_t obaud; // output baud rate
yes the unknown opcode is reproducable on my system
so that is another issue to look into
could be related to the amd bug but idk
gut feeling?
yeah
fair
this kernel is all but gut feelings and hopes and dreams lol
i see this unknown opcode occurs when PRESSING a key
so it could be related to keyboard handling logic in nano/ncurses
yea
i thought it was just unconditional
c_line is the line discipline
The structure termios contains the c_line (line discipline) element, which is not used in POSIX compliant systems.
https://tldp.org/HOWTO/pdf/Serial-Programming-HOWTO.pdf
NOT USED
LITERARLY NOT USED
insane
@surreal path on the #UD: when the read syscall unblocks and returns to userspace, it seems to corrupt the user stack
very weird??
how trf
tf*
it's not what's causing the stack corruption and #UD but this bug results in any user page fault succeeding, even if it's not meant to be mapped ```patch
diff --git a/kernel/src/mem/vmm.c b/kernel/src/mem/vmm.c
index 3a4fca9..ab54472 100644
--- a/kernel/src/mem/vmm.c
+++ b/kernel/src/mem/vmm.c
@@ -141,6 +141,7 @@ bool iswithinvmmregion(pagemap *map, uint64_t virt) {
}
cur = (VMMRegion *)cur->next;
}
- return false;
}
void *uvmm_region_alloc_demend_paged(pagemap *map, uint64_t amount) {
assert(ker_map.userhead != NULL);```
good fine
find*
which delayed the exception until rip collided with a page that had actual data
very weird tho
could it be related to elf.c?
i heard leo say before it was gonna cause issues down the line
the way i load elfs
i dont know why though, dont remember what he said
but might be good to investigate elf.c
trying to figure out if i can use watchpoints to track down the moment the stack gets corrupted first but i'll take a look
hold on could u try allocating everything with backing pages, might help to see
maybe theres different behavior
oh yeah and bash bug with chars not appearing until u press backspace is back weirdly
idk why tho
might just be a quirk on my machine ™️
i get that as well
weird
ah it's not user stack corruption, it's register corruption
rsp gets changed from 0x1003e8 to 0x100a38
syscall_waitpid does cpu->cur_thread->syscall_user_sp = cpu->arch_data.syscall_stack_ptr_tmp;, which is missing from all other syscalls - is this required for syscalls to block?
yes
ah that's what's happening then
read blocks, so bash gets scheduled, which does waitpid and changes the value that syscall_entry loads into rsp
syscall_read upon returning doesn't restore it
i think it'd be less error prone if the scheduler did this save/restore
yeah i'll add it to syscall_read and see if it fixes it
well the panic is gone but the chars don't get displayed and it occasionally prints cannot stop wont stop
if u check the patch of nano
youll see where this appears from
it seems to be stuck with the keyboard buffer
ah
and reallocating to infinitely
well no it's not like every x seconds it prints it, it's every x keypresses
so i assume it just doesn't pop from the buffer for some reason
u can look at the source in nano and patch it accordinly to investigate
sources/nano-workdir
make sure to run ./jinx regenerate nano
which will regenerate the patch
i have a gut feeling this is related to the bash prompt issue
same
anyway it's like 11 pm where i am so i'm going to sleep
here's the patch that fixes the stack issue ```patch
diff --git a/kernel/src/arch/x86_64/syscalls/syscall.c b/kernel/src/arch/x86_64/syscalls/syscall.c
index a01140b..c5df7c9 100644
--- a/kernel/src/arch/x86_64/syscalls/syscall.c
+++ b/kernel/src/arch/x86_64/syscalls/syscall.c
@@ -99,6 +99,8 @@ struct __syscall_ret syscall_read(int fd, void *buf, size_t count) {
if (hnd->node == NULL) {
return (struct __syscall_ret){.ret = -1, .errno = EIO};
}
- struct per_cpu_data *cpu = arch_get_per_cpu_data();
- cpu->cur_thread->syscall_user_sp = cpu->arch_data.syscall_stack_ptr_tmp;
if (count > (hnd->node->stat.size - hnd->offset) &&
hnd->node->stat.size != 0 && hnd->node->v_type != VCHRDEVICE) {
count = hnd->node->stat.size - hnd->offset;
@@ -110,6 +112,7 @@ struct __syscall_ret syscall_read(int fd, void *buf, size_t count) {
return (struct __syscall_ret){.ret = -1, .errno = res};
}
hnd->offset += bytes_read; - cpu->arch_data.syscall_stack_ptr_tmp = cpu->cur_thread->syscall_user_sp;
return (struct __syscall_ret){.ret = bytes_read, .errno = 0};
}
struct __syscall_ret syscall_close(int fd) {```
thanks
ill investigate the bash and nano keyboard buffer issue
thank you for your help
again, if theres anything i can do to repay you. like maybe contribute to andromada or somt lmk
i already have a bucket list of projects to contribute to lol
ive contributed to mlibc
and im doing ironclad next
i may not be a great programmer but hopefully i can provide help or smt, also same goes for u @molten grotto if u ever want me to contribute something :)
it's fine, debugging this was pretty fun imo, you don't have to repay me or anything
i wouldnt call that fun but everyone has their own versions of pain 
plus most of my own projects are the kinda thing I wouldn't accept any contributions to, I do them because I want to write everything myself
ty
np
If you don't like it/don't consent then tell them that
i feel kinda numb so idk
It's not worth it risking being raped
It's a thing you have to decide
im fine with it i think?
I am too much of a nerd
be skinny and short
Talk with her about it
Sooner rather than later
like she was my previous ex
Don't be worried about losing her by talking with her, if you raising concerns makes her leave, it wasn't going to work anyway
I would be SUPER careful
ill talk abt it with her tmrw dw
The amount of red flags here genuinely concerns me 🥺
ill take care dw 🥺
🥺 💙
this one doesn't work for me
can't reproduce that behavior
- 95lbs
- 5ft 2"
- no bitches
i feel so sick
🫂 💙
🫂

🫂 💙
❤️
being sick is not absolute cinema :(
relative cinema
While I do find these jokes hilarious maybe consider making fun of him elsewhere considering it's a serious matter 💀
It’s fine I know they are being light hearted about it
@surreal path i saw you on the vinegar server, can you show me your places please 🥺
fix ncurses memes
nice
@surreal pathquestion
have you ever dealt with a bug where the PTE is valid accessible and can be executed from yet for some whatever reason it doesnt want to execute
and just keeps page faulting
cause i am
and i have no idea why it would keep PFing
not really sorry :c
rip
I'll send to you friend request
nvm i got worse
😔
Get well soon (threateningly)
i know why the issue happens
i did this by just reading logs i didnt write shit cause im still sick
old
so basically
thats in decimal
and fd 0 and fd 1 and fd 2 flags are all set to 0
they arent changed by the openat syscall
causing this issue
no i do
nvm
if tty is opened with these flags does it expect stdin and stdout to have those flags too?
ayu dark mention 🗣️ 🗣️ WTF IS A BAD THEME?
like how should this even work
most of the flags are for the file description, so all file descriptors to it share the same flags
atp how am i supposed to attach fd 0 1 and 2
getting it to follow the flags
taking a quick look at the code it seems you already do, through the dummy and realhnd fields
not really?
like, fd 1 and 2 should be dup'd from fd 0, which should be open'd from the tty device
so fd 1 and 2 point to the same handle and same flags as fd 0 through the realhnd thing
yes but fd 0 flags are zero
oh right
right so on process init fds 0..2 are allocated but don't point to any vnode
yep
idk what assumptions bash makes about fd state but most kernels open the tty for the init process and makes fd 0..2 point to that file description
i can make an init process that does this
https://github.com/monkuous/andromeda/blob/5e06d74ea49295333386191dab2db77dc7a062d5/sources/andromeda-kernel/kernel/drv/console/console.c#L545 for reference this is where Andromeda does that
Contribute to monkuous/andromeda development by creating an account on GitHub.
allocassoc is kinda like dup2
files can be opened
by that it could mean a creation of a new file descriptor
pointing to a vnode
yes
but can i actually have a vnode->open() op as well
that would just return a file descriptor
vfs designs have left the chat 
how does ur kernel setup fd 0 1 and 2
and its flags
for example
say /bin/bash opens /dev/tty with flags
do u just copy them over to the stdin stdout and stderr
how does that even work
@edgy pilot ?

everyone goes offline
:c
current one doesn't yet
old branch did
honestly, I don't remember how things worked
it's been years
Bash does itself
With dup2 etc
You can assign any fd to any other fd
no this is not true, on devtty_init
it is associtated
the problem is /dev/tty is opened with flags
and those flags arent reflecting on 0..2
Which flags tho
openat returns a new file description, existing file descriptions (like the one that fds 0..2 point to) keep their initial flags
me when no manpages
I know
But bash is opening tty with ononblock
yeah so the new fd returned by openat had o_nonblock, fds 0..2 don't
But it reads from fd 0 expecting a non blocking read
oh hmm
ohh wait
do you have a stub implementation for pselect?
if so, it might be expecting a non blocking read because pselect returned it as readable
Yes
yeah for ttys bash will use pselect before reading
and a stub implementation of pselect would always say "hey all the fds you asked me about can be read without blocking"
how does pselect even work
I’m not home on the pc so can’t check man pages
like what does pselect do
Pselect checks a list of fds and returns whether each one is ready for reading/writing
And it blocks until at least one fd is ready for at least one thing
and that can include telling bash that an fd can be read without blocking??
Yeah, if pselect says "hey this fd is ready for reading" that means it can be read without blocking
I believe stdin is the only fd bash passes to it, so you're supposed to block until it's ready
In pselect?
yeah
how do u implement it?
File descriptions have three related functions: poll, which returns all the events it's ready for (so ready for reading and writing would be POLLIN | POLLOUT); poll_submit, which adds the current thread to a list of threads that will be woken up if the poll status changes, and poll_cancel, which removes the current thread from the aforementioned list. I first set up a pselect context by resolving all the fds. I then do a single "pselect iteration", which runs poll on all the file descriptions, and I return if there are any matching events. If not, and the caller hasn't requested non-blocking operation, I run poll_submit on each file description, then go to sleep. Every time the thread's awoken, I run a poll iteration again, and if it doesn't find any, go to sleep again. If it does find an event, I run poll_cancel on each file description, and return
same
is there a way i can stub this in a way to get it to work or do i really have to implement pselect

because it looks like a really complicated syscall
I don't think so unfortunately. You might be able to use a hacky implementation that only works for the specific params bash passes, but I believe bash just exits immediately if pselect errors, so that isn't an option
im going to struggle with the implementation of pselect then
because it looks very complicated
It's complicated yeah, but it's better to get it out of the way early imo
Every poll-capable file and device needs to be written with it in mind, so that things blocking in a pselect/poll of that file get woken up when appropriate
It's easier to take that into account and test when you already have it
can i just spin in pselect instead
instead of having to do the whole thing of blocking the thread and putting it in some queue or smt
Like just literally polling the files and yielding if you don't get anything? I'm pretty sure that's a valid implementation yeah
okay
now i have to learn what polling is
In this context, it's asking the files "hey are you ready to do <x> without blocking"
so basically checking if data is ready
Yep
ppoll() is cringe
poll is cringe
pselect is cringe
ban bash for ever trying to pselect shit
time to implement this the vinix way ™️
vinix
i swear to god
if u weren't written in V ill make u C pain
get it?
C pain?
hahahahahaha
dear mintsuki
wtf
signed rayan
@surreal path i have a question
are you going to take care of some glaring bugs i found in your syscalls?
whats wrong
not only does this allow you to crash the kernel, it also allows you to read from arbitrary kernel memory
buf isn't sanitized or checked for validity at all
thats on purpose
nyauxkc: not a secure kernel?
because i trust userspace with all my heart
userspace would never do something bad ™️
thanks
i have a paranoia with userspace so i employ measures to stop it from abusing anything
just end game ur local at&t employee
finished

blame everything on unix design then implement it anyway
but are you going to fix them, ever?
or just leave them wide open for exploitation like that
the security issues?
nah leave em WIDE open
let userspace abuse the shit out of it idfc
yea
i dont care about security in this kernel
not like anyones gonna run this kernel as their main os
would be a noble goal
i was actually going to santizie and verify the buffers userspace gives but @thorn bramble pushed me in the right direction considering i dont care about security anywhere else in the kernel
almost nobody cares about it
almost ™️
i wouldnt say "pushed me in the right direction"
well lets see who does
blame him for it

