Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running on Termux asserts #66

Open
0dminnimda opened this issue Oct 29, 2024 · 8 comments
Open

Running on Termux asserts #66

0dminnimda opened this issue Oct 29, 2024 · 8 comments

Comments

@0dminnimda
Copy link

Tried to run it on termux proot-distro and got such kinds of errors:

/data/data/com.termux/files/home/.../odin-http/server.odin(141:2) runtime assertion: errno == os.ERROR_NONE
/data/data/com.termux/files/home/.../odin-http/nbio/_io_uring/os.odin(94:2) runtime assertion: (params.features & IORING_FEAT_SINGLE_MMAP) != 0
@laytan
Copy link
Owner

laytan commented Oct 29, 2024

It probably doesn't support IO Uring.

It's in the plans to have an alternative backend to choose from but that's a bit away.

@0dminnimda
Copy link
Author

0dminnimda commented Oct 29, 2024

It appears to be supported

$ sudo grep io_uring_setup /proc/kallsyms
0000000000000000 T __arm64_sys_io_uring_setup
0000000000000000 t __arm64_sys_io_uring_setup.cfi_jt
0000000000000000 d _eil_addr___arm64_sys_io_uring_setup

But

#include <errno.h>
#include <linux/io_uring.h>
#include <stddef.h>
#include <sys/syscall.h>
#include <unistd.h>
#include <stdio.h>

int main(int argc, char **argv) {
  if (syscall(__NR_io_uring_register, 0, IORING_UNREGISTER_BUFFERS, NULL, 0) && errno == ENOSYS) {
    printf("No io_uring\n");
  } else {
    printf("Ye io_uring\n");
  }
}

is not accessible from proot-distro

[root@localhost ...]# ./test_io_uring.o
No io_uring

while not working in usual mode, and working in sudo

$ ./test_io_uring.o
Bad system call
$ sudo ./test_io_uring.o
Ye io_uring

Oh how fun it is working from android ;)

@laytan
Copy link
Owner

laytan commented Oct 30, 2024

Aha, so it doesn't assert when running in sudo then?

@0dminnimda
Copy link
Author

Unfortunately I cannot check for this right now. I cannot get odin to compile on regular termux, because its libllvm is version 19, which is not supported by odin. I didn't have enough time to look into the underlying reason/hack it.

@0dminnimda
Copy link
Author

0dminnimda commented Nov 6, 2024

After some modifications to the odin, I was able to get this working. The only thing that confused me at first is that the example server does not serve the / which made me first think that the server was not properly running. Second thing is that it's not cancallable with Ctrl-C. That's quite bad to have to go to ps aux to shut down the server immideately. While pressing Ctrl-D will print [2024-11-06 18:07:29] [server.odin:289:_server_thread_shutdown()] shutdown: done but the program remained running for quite some time, finally stopping after about a minute.

But overall looking fowrard to using it.

@0dminnimda
Copy link
Author

So / and /index serve an html file. Wold be nice to mention that in the readme!

@laytan
Copy link
Owner

laytan commented Nov 6, 2024

What do you mean?

@0dminnimda
Copy link
Author

0dminnimda commented Nov 6, 2024

Example in the readme serves an html file for /index. So just compiling and running the example can lead to confusion, as the index will error 404

index :: proc(req: ^http.Request, res: ^http.Response) {
	http.respond_file(res, "examples/complete/static/index.html")
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants