#Nyaux

1 messages · Page 53 of 1

surreal path
#

yea @molten grotto recompiling bash works

#

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

molten grotto
surreal path
#

@edgy pilot

#

fix ur flanterm fork

#

pls

ionic musk
surreal path
#

3 weeks ago u worked on it

#

im considering switching back to mints branch atp

#

if ur not gonna mantain it

#

😡

flat nymph
#

Why was it forked in the first place?

surreal path
#

sixel support

flat nymph
#

(I'm still using 1 year old version and it works fine trl)

edgy pilot
silver yarrow
#

lol

#

welcome to maintaining open source projects

surreal path
#

rn

edgy pilot
#

what do you want fixed then mr

surreal path
#

theres some bug with sixel

edgy pilot
#

no

surreal path
#

thats crazy

edgy pilot
#

as I said, it was just an experiment

surreal path
surreal path
median goblet
#

nice

kind root
surreal path
surreal path
#

time to debug why nano is using canoical mode??

kind root
#

Just port vim instead trl

surreal path
#

😭

thorn bramble
coral dove
surreal path
thorn bramble
#

instead of "debugging" why it uses a properly supported feature you should implement it

thorn bramble
#

good

surreal path
#

so why is it not getting characters

#

and only enter works

thorn bramble
#

because you implemented it incorrectly probably

surreal path
#

and moves the cursor down

#

no but shouldnt nano be using raw mode

#

first off

#

and second off

thorn bramble
#

no idea lmao

surreal path
#
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

coral dove
surreal path
#

otherwise i will do this

thorn bramble
#

i don't think that's correct brother

#

or Maybe it is

#

who knows

#

not me!

#

I love spreading misinformation :3

surreal path
#

bru

coral dove
surreal path
coral dove
# surreal path ?

You said “shouldn’t nano be in raw mode” and I read it as “nano shouldn’t be in raw mode”

flat nymph
coral dove
cinder plinth
surreal path
#

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

surreal path
#

sorry what

#

0xa??????

#

wtf did u change

surreal path
#

progress

#

raw() returned -1

flat nymph
#

Ironclad reference?!

surreal path
#

maybe

#

@alpine mulch trl

surreal path
#

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

surreal path
#

what

edgy pilot
#

it's called cooked mode

surreal path
#

man page says cannoical

edgy pilot
#

man page is cringe

brisk zenith
#

posix says canonical as well

crystal scarab
tender gorge
#

(in fact, real names)

kind root
desert haven
#

cooking transforms stuff

brisk zenith
#

the raw input and output is cooked into a nicer form

tender gorge
bleak cedar
#

They really have been cooking with this rare w name choice

surreal path
#

i cant get cannoical or raw mode right for userspace to accept it nooo

surreal path
#

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)

coral dove
#

We love you man

#

Don’t ever rush the OS

surreal path
#

thanks

coral dove
#

you’re very talented and we care about your health brother

surreal path
#

thank you :)

surreal path
#

ive read this

thorny glen
#

not helpful then

#

L

surreal path
#

blame the article for not bothering on explaining implementation side of things

#

and just pointing me to fucking linux source code

#

yea thats fun

#

:^)

coral dove
gilded mantle
gilded mantle
#

yeah 😭

surreal path
#

what is that?

gilded mantle
#

'\n' to '\r\n' and vice versa

#

iflags IGNCR, ICRNL, INLCR

surreal path
gilded mantle
surreal path
brisk zenith
#

Ctrl+J

#

since ctrl just strips off bits 5 and 6 of what the character would've been

surreal path
brisk zenith
#

yeah i only figured it out when implementing my vt

surreal path
#

in raw mode does every character get printed by the program or by the vt itself?

gilded mantle
#

program

#

it's controlled by echo and echoe in canon mode

brisk zenith
#

echo is actually independent of canon but yeah

surreal path
brisk zenith
#

this is what posix says about it

#

ECHO doesn't have the ".. and ICANON .." part

surreal path
#

i see

surreal path
edgy pilot
#

I had a similar issue recently

#

turn off optimisations and lto if you have them

coral dove
surreal path
#

i dissabled optimiztiations and its still doing this

flat nymph
# flat nymph

(at some point my kernel wasn't working without optimizations)

edgy pilot
surreal path
#

im gonna cry in a corner

flat nymph
surreal path
flat nymph
#

yeah

surreal path
#

not yet

#

hold on

#

ill push it

#

its pushed @flat nymph

#

@flat nymph join vc

surreal path
#

@flat nymph sorry for leaving

surreal path
#

needed to recompile my userspace

#

interesting

edgy pilot
#

me when base 10: nooo

thorn bramble
surreal path
#

i fell asleep

tender gorge
#

Hi Rayan 🫂 💙

edgy pilot
surreal path
#

time to put printfs all over nano source code

surreal path
#

😡

median goblet
#

i just said nice

surreal path
#

(thought it was obvious with the rage face lmao)

#

bagel ur morning

median goblet
#

also have i never spoken before in this thread wtf

surreal path
#

i think

median goblet
#

no i spoke at least twice

#

and yea

surreal path
#

oh i see

#

5 times trl

broken depot
#

And then the whole diagram of a pipe thing happened KEKW

flat nymph
#

Wait, how do you search within a thread?

silver yarrow
#

afaik, you dont

#

lmao

#

it lets u do it within the "threads channel"

surreal path
#

nano is infinitely allocating here

#

somewhere in this function

#

dies

surreal path
#

infitely allocating here

median goblet
#

I had to find messages in the progress report thread channel which shows messages from all threads

flat nymph
surreal path
#

no

#

not really

velvet fog
median goblet
#

i think the program that breaks expectations looks like this

#include<stdio.h>
int main() {
    while(1);
}
void what() {
    printf("what???");
}
surreal path
#

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 nooo

molten grotto
# median goblet yes

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)

median goblet
surreal path
#

richard stallman laughing with his beard

edgy pilot
#

it was a "bug" in clang that has been fixed recently

median goblet
#

i am being gaslighted wtf

#

it used to be a thing

edgy pilot
#

it used to be

median goblet
#

wow

#

so it was a clang bug?

edgy pilot
#

""""bug""""

#

it's UB

surreal path
#

ncurses code looks like shit as usual

#

so

molten grotto
#

not anymore

edgy pilot
#

in C++

surreal path
#

back to trying to understand ncurses code for like 50 hours lmao

#

#ihategnustylecode

edgy pilot
#

I believe it's still UB in C

surreal path
#

#gnudevelopersshouldbepolitelysenttocastledungeons

edgy pilot
#

I remember reading a proposal for C++ to define that loop

surreal path
#

its either gnu code is too big brain for me to understand

#

or its too shit for me to read

edgy pilot
#

I don't exactly remember what it said though

#

it was at least a few months ago

surreal path
#

genuinely

#

i should make a gnu code style bingo card

#
  1. shit indentation
edgy pilot
#

P2809R1

#

yep

surreal path
#
  1. macros everywhere
molten grotto
edgy pilot
#

true

#

it was a C++ proposal and I assumed it only applied to C++ lol

molten grotto
#

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

surreal path
#

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

broken depot
#

ncurses suck to deal with

surreal path
#

and i have no idea why ncurses is not happy

broken depot
#

arbitrary reasons

surreal path
#

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

surreal path
# surreal path <@379250891838193667>

@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

unkempt relic
#

nyaux is progressing remarkably well

surreal path
#

taking a break today cause im too frustrated with ncurses

#

as per usual

#

now i shall sleep

surreal path
broken depot
#

Yeah Nyaux progress recently is absolutely legendary

kind root
#

Yes

#

When I start my os i probably won't reach nyaux levels until like a year into the project or even later sad

surreal path
surreal path
#

also opinion on chocolate egg

edgy pilot
surreal path
#

i feel so poop today :c

surreal path
#

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 🥺

#

🥺 🙏

surreal path
#

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

surreal path
#

okay so

surreal path
#

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

molten grotto
#

maybe, idk

surreal path
surreal path
#

is this not allowed

#

does this break abi

#

okay i see

tender gorge
surreal path
flat nymph
#

Can I rewrite your context switching code? trl

surreal path
#

as long as it doesnt break stuff

flat nymph
#

Ok, I'll look into it tomorrow

surreal path
# surreal path

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

#

?

surreal path
elder shoal
surreal path
flat nymph
surreal path
#

i will work on nyaux maybe tmrw idk i feel like poo

surreal path
#

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

molten grotto
#

what did you change that made it not work

surreal path
#
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

molten grotto
#

I don't think bash uses raw mode

surreal path
molten grotto
#

actually wait yeah, I were thinking of the wrong thing lol

surreal path
#

?

molten grotto
#

for what flags

surreal path
#

fd flags

molten grotto
#

like non blocking etc?

surreal path
molten grotto
#

I'd probably just have an argument for them in the op functions

#

because open files aren't really tightly coupled to vnodes

surreal path
molten grotto
#

you could move the options to a struct

surreal path
#

yea i still have to add a parameter to them

#

this is fine

median goblet
#

like separate read and write members

surreal path
#

idk

rigid fable
#

I'm sorry I'll shush now..

molten grotto
#

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

molten grotto
#

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)

surreal path
#

bash did not supply nonblocking

surreal path
#

yea im still stuck at this

molten grotto
#

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

surreal path
#

it only supplys 2050

molten grotto
#

and that includes the flag

surreal path
#

how

molten grotto
#

the flag in the header is in octal

#

you print in decimal

surreal path
molten grotto
#

yes its what the zero prefix does

surreal path
#

and it isnt non blocking cause it didnt go through

molten grotto
#

when I tried it it went inside the canon if and didn't enter the blocking loop

surreal path
#

doesnt print

molten grotto
#

I can try again after I get back home in a bit but iirc

surreal path
#

cause im hella lost as to why this isnt working lol

surreal path
#

@molten grotto u home?

molten grotto
#

yes

surreal path
#

im sure its the same result

molten grotto
#

ah I didn't have rebuilt mlibc, after your dup2 impl it looks like that thing happens where bash doesn't display the chars

surreal path
#

i dont know why :c

#

try to have a look if u can cause im stuck nooo

surreal path
#

oh yeah @molten grotto returning enosys in dup2 doesnt fix ze issue either

#

thats interesting flags is 0

#

yea weird

surreal path
#

: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?

molten grotto
#

I think I found the problem

surreal path
#

What is it

molten grotto
#

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

surreal path
#

Where in the man page does it say that?

molten grotto
surreal path
#

I see

surreal path
molten grotto
surreal path
#

yea that solved the bash issue

#

time to test nano

#

again

surreal path
#

fucking hell ncurses

#

wtf ncurses like bro

#

what do u want

broken depot
#

Does ncurses actually want vmin and vtime to be 0?

surreal path
broken depot
#

That's what I'd figure out next

surreal path
#

it didnt request to change it tho

#

and bash changed it to be 0

broken depot
#

something to look into ¯_(ツ)_/¯

surreal path
# molten grotto

if i set vtime to 5 initially bash is no longer happy and does the same bug again

#

whats up with that?

molten grotto
#

idk tbh

surreal path
#

back to debugging dungeon nooo

surreal path
#

maybe theres a reason ?

surreal path
#

cant figure this out

surreal path
#

im cooked

#

ill ask korona or smt maybe when hes back in vc about this cause im just nooo

surreal path
#

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

#

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

surreal path
#

debiggomg mpw

#

debugging now

surreal path
#

(i havent updated in months)

edgy pilot
#

api has been stable after 1.0

surreal path
edgy pilot
#

I know, crazy

surreal path
#

crazy indeed

kind root
#

yeah api is stable now

#

if api changes it will be a major version bump

surreal path
#

okay i see

flat nymph
kind root
#

ROS is WIP

#

The guy from haiku just disappeared so no idea whats happening there

surreal path
#

i am the stupidest

#

stupidest

#

bro

#

i was returning read 1 byte even tho i read 0 bytes

#

💀

surreal path
#

yea bash exits from that, like bro what am i supposed to say

surreal path
#

nvm

#

nothing is fixed

#

at all

#

ill ask qwinci for help when hes online

surreal path
#

fuck i fell asleep

tender gorge
kind root
surreal path
#

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

tender gorge
surreal path
#

i fell asleep again :(

broken depot
#

Wasn't that your goal?

surreal path
#

what no

#

i slept all day

broken depot
#

Something about differing timezones

surreal path
#

im sorry im having really bad days atm

#

no development or debugging until tmre

#

even tmrw is a maybe

#

i had an awful day.

plush hearth
#

Take your time. Don't force yourself to work on this if you don't want to. Also, I hope you feel better soon.

edgy pilot
#

@surreal path how do you even make deltarune last that long

#

content runs out

#

or do you just play again but different paths

surreal path
surreal path
#

i might work today

#

or tmrw depending

#

on my mood

surreal path
#

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

molten grotto
#

not really

surreal path
molten grotto
#

do you still have the same weird tty problem

surreal path
#

yes

molten grotto
#

ttys kinda suck ngl

surreal path
#

fr\

#

ncurses makes me wanna visit the developers irl

molten grotto
#

what was the problem again

#

I forgot

surreal path
#

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

surreal path
#

vtime and vmin are still 0 so read does polling and ncurses wants blocking

#

yea i remember

surreal path
edgy pilot
#

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

surreal path
#

yea not until u actually RUN ncurses, which means running nano

#

bash is compiled with ncurses

surreal path
edgy pilot
surreal path
#

it does its own shit for input

edgy pilot
edgy pilot
surreal path
surreal path
surreal path
#

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

edgy pilot
surreal path
#

no

edgy pilot
#

maybe fix that first

surreal path
#

vtime is always 0

#

its never changed by bash OR ncurses

#

and typically that should be fine

edgy pilot
#

is ioctl with tcsets never called?

brisk zenith
#

my bootloader ignores vtime and it runs bash and nano with ncurses just fine

surreal path
#

it is, but VTIME isnt changed

brisk zenith
#

code style is a bit unique because it's a cpu-local kernel stack so blocking uses continuations but still

surreal path
#

how come eagain doesnt kill bash or ncurses for you

#

it kills bash and ncurses for me

brisk zenith
#

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

edgy pilot
surreal path
#

yea i dont really see anything too obvious

#

other then vmin being set to 1 and u doing eagain

#

which is probs never returned

brisk zenith
#

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?

surreal path
brisk zenith
#

wait, why 5?

surreal path
#

idk

#

thats what managarm did ™️

brisk zenith
#

i just did tcgetattr from one of my host's vts and copied the values returned

surreal path
#

ill try setting vmin to 1 and see if that helps

#

yea that doesnt fix anything

brisk zenith
#

looks like managarm just sets it to the values from sys/ttydefaults.h by default

brisk zenith
#

you're comparing the size to the index of vmin, not its value

surreal path
#

i will try seeing what that changes

#

nope

#

doesnt solve it

surreal path
#

still attempting to debug it

#

havent found anything useful

#

still

brisk zenith
#

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

surreal path
#

huh??????????????????????????????????????????????????????????????????????????????????????????????

#

are u running amd

brisk zenith
#

yeah

surreal path
#

i think this might be the amd bug @tender gorge mentioned

#

:c so ur gonana have to sport tcg for now

brisk zenith
#

that's fine

surreal path
#

sorry i cannot debug that since im not on amd

brisk zenith
#

i am very unfamiliar with jinx, what's the command to rebuild a package

surreal path
brisk zenith
#

ah ty

surreal path
#

np

surreal path
#

@brisk zenith did u find anything

brisk zenith
#

still looking

surreal path
#

alright

brisk zenith
#

rn i'm investigating why vmin and vtime get set to 0

#

because i don't observe that behavior on other systems

surreal path
#

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 nooo

#

if theres any way i can return the favour i will do so

brisk zenith
#

right well i can say that readline at least tries to set vmin=1

#

still trying to find where it gets fucked

surreal path
brisk zenith
#

this is my favorite kind of debugging

surreal path
brisk zenith
# brisk zenith rn i'm investigating why vmin and vtime get set to 0

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

surreal path
#

huhhhhh

#

tf is c_line

brisk zenith
#

no clue but it's there in the abi-bits struct

brisk zenith
#

it panics with an undefined opcode exception

#

which is definitely different

surreal path
#

well thanks for finding it!

brisk zenith
#

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]

brisk zenith
#

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;```
    
surreal path
#

could u give the patch header too

brisk zenith
#

one second i'm trying to get rid of all the extra newlines added to files i didn't need to change

surreal path
#

no its all good dw

#

i just applied yet

brisk zenith
#

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
surreal path
#

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

brisk zenith
#

i doubt it

#

just doesn't really feel like the same issue

surreal path
#

gut feeling?

brisk zenith
#

yeah

surreal path
#

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

brisk zenith
#

oh yeah it happens a few seconds after pressing a key

#

that's interesting

surreal path
#

yea

brisk zenith
#

i thought it was just unconditional

tawdry mirage
#

c_line is the line discipline

surreal path
#

LITERARLY NOT USED

#

insane

brisk zenith
#

@surreal path on the #UD: when the read syscall unblocks and returns to userspace, it seems to corrupt the user stack

brisk zenith
#

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);```
brisk zenith
#

which delayed the exception until rip collided with a page that had actual data

surreal path
#

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

brisk zenith
#

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

surreal path
#

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 ™️

brisk zenith
#

i get that as well

surreal path
#

weird

brisk zenith
#

ah it's not user stack corruption, it's register corruption

#

rsp gets changed from 0x1003e8 to 0x100a38

surreal path
#

tf??

#

whats causing this

brisk zenith
#

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?

brisk zenith
#

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

surreal path
#

yea makes sense

#

its fine

#

just add the statement to before and after blocking

brisk zenith
#

yeah i'll add it to syscall_read and see if it fixes it

surreal path
#

see if it fixes it

#

yea

brisk zenith
#

well the panic is gone but the chars don't get displayed and it occasionally prints cannot stop wont stop

surreal path
#

youll see where this appears from

#

it seems to be stuck with the keyboard buffer

brisk zenith
#

ah

surreal path
#

and reallocating to infinitely

brisk zenith
#

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

surreal path
#

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

brisk zenith
#

i have a gut feeling this is related to the bash prompt issue

surreal path
#

same

brisk zenith
#

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) {```
surreal path
#

thanks

#

ill investigate the bash and nano keyboard buffer issue

#

thank you for your help

brisk zenith
#

no problem

#

didn't really have anything better to do anyway

surreal path
#

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

brisk zenith
#

it's fine, debugging this was pretty fun imo, you don't have to repay me or anything

surreal path
#

i wouldnt call that fun but everyone has their own versions of pain nooo

brisk zenith
#

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

surreal path
#

understandable

#

have a good sleep :)

brisk zenith
#

ty

surreal path
#

np

surreal path
#

ummmm i think i have a gf now?

#

this girl kinda just forced her on me

tender gorge
surreal path
tender gorge
#

It's not worth it risking being raped

edgy pilot
#

how

#

teach me this power

tender gorge
surreal path
surreal path
#

be nerd

edgy pilot
#

I am too much of a nerd

surreal path
#

be skinny and short

tender gorge
#

Sooner rather than later

surreal path
tender gorge
#

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

tender gorge
surreal path
#

ill talk abt it with her tmrw dw

tender gorge
#

The amount of red flags here genuinely concerns me 🥺

surreal path
tender gorge
#

🥺 💙

orchid dawn
#

can't reproduce that behavior

#
  • 95lbs
  • 5ft 2"
  • no bitches
surreal path
#

i feel so sick

tender gorge
surreal path
broken depot
surreal path
#

im still not doing too good

#

no development on nyaux for a while til i feel better

tender gorge
#

🫂 💙

frigid cliff
#

❤️

surreal path
#

being sick is not absolute cinema :(

edgy pilot
#

relative cinema

worn rain
#

While I do find these jokes hilarious maybe consider making fun of him elsewhere considering it's a serious matter 💀

surreal path
#

It’s fine I know they are being light hearted about it

ebon needle
#

@surreal path i saw you on the vinegar server, can you show me your places please 🥺

surreal path
#

rayan_thevrman

#

thats the roblox user

surreal path
#

i feel better enough

#

so im ready to work on nyaux now

kind root
#

LFG

#

What's currently planned for it

surreal path
#

fix ncurses memes

kind root
#

nice

median goblet
#

@surreal pathquestion

surreal path
#

and then ill probs get to work on porting doom over by getting fbdev working

#

yea?

median goblet
#

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

surreal path
#

not really sorry :c

median goblet
#

rip

ebon needle
ebon needle
#

unavailable 😔

surreal path
frigid cliff
#

Hope you get better soon

ebon needle
tender gorge
#

get well soon

rich trellis
#

its a order

broken depot
#

Get well soon (threateningly)

surreal path
#

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?

cinder plinth
surreal path
brisk zenith
surreal path
#

getting it to follow the flags

brisk zenith
#

taking a quick look at the code it seems you already do, through the dummy and realhnd fields

brisk zenith
#

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

surreal path
#

yes but fd 0 flags are zero

brisk zenith
#

oh right

surreal path
#

if u see the process init code in sched

#

youd see what i mean

brisk zenith
#

right so on process init fds 0..2 are allocated but don't point to any vnode

surreal path
#

yep

brisk zenith
#

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

surreal path
brisk zenith
#

allocassoc is kinda like dup2

surreal path
#

can vnodes be "opened"

#

like can i add an open operation in the vfs

edgy pilot
#

files can be opened

surreal path
#

pointing to a vnode

edgy pilot
#

yes

surreal path
#

but can i actually have a vnode->open() op as well

edgy pilot
#

that would just return a file descriptor

surreal path
#

then nvm

#

ill have to

#

hack my way around this

edgy pilot
#

vfs designs have left the chat trl

surreal path
#

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

edgy pilot
#

honestly, I don't remember how things worked

#

it's been years

kind root
#

With dup2 etc

#

You can assign any fd to any other fd

surreal path
#

thats not what i mean

#

i mean the flags

surreal path
#

it is associtated

#

the problem is /dev/tty is opened with flags

#

and those flags arent reflecting on 0..2

kind root
#

Which flags tho

surreal path
#

Flags from opener

#

Openat *

brisk zenith
#

openat returns a new file description, existing file descriptions (like the one that fds 0..2 point to) keep their initial flags

edgy pilot
#

me when no manpages

surreal path
#

But bash is opening tty with ononblock

brisk zenith
#

yeah so the new fd returned by openat had o_nonblock, fds 0..2 don't

surreal path
#

But it reads from fd 0 expecting a non blocking read

brisk zenith
#

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

surreal path
#

Yes

brisk zenith
#

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"

surreal path
#

how does pselect even work

#

I’m not home on the pc so can’t check man pages

#

like what does pselect do

brisk zenith
#

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

surreal path
#

and that can include telling bash that an fd can be read without blocking??

brisk zenith
#

Yeah, if pselect says "hey this fd is ready for reading" that means it can be read without blocking

surreal path
#

Am I supposed to say it’s not ready?

#

then

brisk zenith
#

I believe stdin is the only fd bash passes to it, so you're supposed to block until it's ready

brisk zenith
#

yeah

surreal path
#

how do u implement it?

brisk zenith
#

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

surreal path
#

hi i slept all day

#

cause sick

#

STILL

kind root
#

same

surreal path
frigid cliff
surreal path
#

because it looks like a really complicated syscall

brisk zenith
surreal path
#

because it looks very complicated

brisk zenith
#

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

surreal path
#

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

brisk zenith
#

Like just literally polling the files and yielding if you don't get anything? I'm pretty sure that's a valid implementation yeah

surreal path
#

now i have to learn what polling is

brisk zenith
#

In this context, it's asking the files "hey are you ready to do <x> without blocking"

surreal path
brisk zenith
#

Yep

surreal path
#

ppoll() is cringe

#

poll is cringe

#

pselect is cringe

#

ban bash for ever trying to pselect shit

#

time to implement this the vinix way ™️

#

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

median goblet
#

@surreal path i have a question

#

are you going to take care of some glaring bugs i found in your syscalls?

surreal path
#

my response

median goblet
#

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

surreal path
#

thats on purpose

median goblet
#

nyauxkc: not a secure kernel?

surreal path
#

because i trust userspace with all my heart

#

userspace would never do something bad ™️

median goblet
#

thanks

#

i have a paranoia with userspace so i employ measures to stop it from abusing anything

surreal path
#

finished

#

blame everything on unix design then implement it anyway

median goblet
#

but are you going to fix them, ever?

#

or just leave them wide open for exploitation like that

surreal path
#

the security issues?

#

nah leave em WIDE open

#

let userspace abuse the shit out of it idfc

median goblet
#

aight, cool

#

different priorities i guess 👍

surreal path
#

yea

#

i dont care about security in this kernel

#

not like anyones gonna run this kernel as their main os

median goblet
#

would be a noble goal

surreal path
#

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

median goblet
#

almost nobody cares about it

surreal path
median goblet
median goblet
surreal path