-
Notifications
You must be signed in to change notification settings - Fork 46
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
Issue with running NodeJS compiled for RISC-V #160
Comments
About the existing unofficial-builds node binary: It could be that the binary needs some kind of relocation that I'm not doing. Regarding the new one you built statically: Just looking at the code in NodeJS it seems to be using signals to do profiling, which is unfortunate as my signal implementation is very very basic. It can remember handlers, and jump to a signal handler, but I'm not sure if it can return properly yet. So, we will see. |
Sure, here is statically linked node |
I have to go to sleep now, but remote GDB has this backtrace:
Signal 6 is SIGABRT. So it's not just a regular exit. Maybe the emulator should have special handling on SIGABRT. |
Maybe. I will dig deeper tomorrow after work too. |
One thing I noticed was the prlimit64 system call is absolute bonkers, as written by me. It will return 0 despite resource not being 3 (rlimit stack). So, I tried checking resource, and as you can guess it's not 3. So, that could be a point of progress. I have committed the changes you made to a PR: #161 It would have been nice to get your work in there, so feel free to remake it with your name on it, if you want. |
https://github.com/nodejs/node/blob/main/deps/uv/src/unix/signal.c#L106-L107 This is the failing spot right now static int uv__signal_unlock(void) {
int r;
char data = 42;
do {
r = write(uv__signal_lock_pipefd[1], &data, sizeof data);
} while (r < 0 && errno == EINTR);
return (r < 0) ? -1 : 0;
} |
EDIT: This turned out to be the 32-bit fast-path thing that avoids bounds-checking for programs fitting in 4GB or less. However, NodeJS seems to at least require mapping 12GB virtual. There's two ways of configuring the emulator:
So we are left with allowing NodeJS 12GB, which is OK. It now runs all the way to a place where the emulator really sucks: futex emulation.
But at least it has created 4 worker threads now. So it's nearing something usable. |
I've gotten v8 with JIT and WebAssembly to work in the emulator now. I guess I can resume trying the NodeJS CLI and see if I can get further. See PR: #161. I will rewrite it soon. |
It's gotten further now. Failing on a
The return value is 35 (EDEADLK), which is mysterious.
Now less mysterious. So it's a special error for rwlocks where one is trying to re-lock the same lock. I think that could indicate that threads are woken up too early and there is no spurious wakeup handling.
This should be the source of the errno. |
After much ado: https://gist.github.com/fwsGonzo/620d36067afc0e3b74028861a086d3bd I had a feeling that it's only the rwlock issue left, so I made a hack to see.
I'm avoiding the deadlock and just unlocking it. After that I got the --help.
|
There is a PR here with the work required to get the basic command-line running: #202 The program opens correctly every time, and closes correctly too. The only thing missing is to figure out where a whole 2 seconds is spent. With or without binary translation it takes exactly ~2 seconds to do anything at all. Where is that time spent? |
One more step forward with #203, now allowing the main decoder to execute normally while only JIT-segments are executed instruction by instruction. With --jitless a simple fibonacci program executes in 900ms.
There are many paths forward, but I doubt it's worth pursuing faster execution of JIT-segments. What would be nice is to fix whatever issue is causing me to have to use a workaround for rwlocks. And maybe there are some low-hanging fruit still to speed up the processing. Another avenue is figuring out why NodeJS HTTP server is stalling. Looks to be in connect(). |
Hi guys. I really love your project and it's awesome.
Currently I'm trying to run NodeJS in libriscv emulator.
Here is my fork with changed configs https://github.com/emcifuntik/unofficial-builds/tree/riscv-toolchain-update
It took me some time to compile NodeJS 20 with riscv toolchain, but now after disabling crypto, i18n and using --fully-static - I'm able to run node --version and I can see correct output, but when I try to simply get --help message it exit with exit code 0. From my investigation it can be related to pthread implementation because exit from program happens on this line https://github.com/nodejs/node/blob/af614c5795851faa5f983f64a6592e270e907ebc/deps/v8/src/libsampler/sampler.cc#L589
To reach this state I needed to implement clock_getres, capget and sigprocmask syscalls.
I'm not sure that it's right, but I simply proxy calls to my host system right now. (Not the best way for emulator) so it looks like this:
Can you suggest maybe some methods to properly debug it or fix?
The text was updated successfully, but these errors were encountered: