-
Notifications
You must be signed in to change notification settings - Fork 291
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
"# Fatal error in , line 0" when trying to run Node app from Rsyslog #4465
Comments
Can you provide a minimal reproducible example? One that doesn't rely on any dependencies or specific unnecessary functions? |
I can try slimming down the app (to the bare minimum, since it even uses ejs to parse an html email template and dotenv for parameters) and try to reproduce it, since it only happens when called from rsyslogd. EDIT: Right after submitting the issue, tried downgrading node to LTS (v20.16.0), same behavior. |
My gut feeling says this may be an issue with a dependency or a system specific issue, but a slim reproduction without any dependencies would help to verify that |
Okay, slimmed down the code to the bare minimum, even removing the axios post. (from 350 lines to 30!) The original app did this: check arguments, if --stdin specified, use readline to read standard input, pass it into a function, check against 4 or 5 regex and keep the results in variables. Then use those variables to populate a json body and post it to another server (also node + express, which it should be next for this migration from debian to rl9) The code it's far from optimal, I do this for hobby and also lacks lots of checks that the original app did, but works for reproducing it. The regex it's matching 3 numbers from 0 to 9 Hello World and the 3 numbers from 0 to 9 (since the original one its over 100 char long and made no sense to post here. Works fine in a CLI using Here is the code, also i've attached the JS with the extension changed to ZIP (its a plaintext file, not a real ZIP) if github messes the format.
|
I'm open to test anything if wanted, but if anyone wants to replicate it, here it's the basic configuration of rsyslog:
I know this is not related to node at all, but I paste it here merely for context and if anyone wants to replicate it on the same way I'm doing it. |
To me, it seems this might be an issue with rsyslog or some other non-node program, but I'm happy to see what others think |
It's possible, but since the crash it's from node, I came here to try to understand what's happening. On the other hand, with the same exact configuration if I make rsyslog pipe the log line to a shell script, it works great, so I don't really have anything to ask for help on rsyslog, they will tell me to kick rocks, lol. I'm open for comments from anyone who has any ideas to try, since I don't have any clue what the stack trace means. |
I would try and debug locally, but I know very little (borderline nothing) about rsyslog. @nodejs/v8 might be able to help with the stack trace. |
Hello I am only somewhat familiar with rsyslog and omprog, and am wanting to reproduce this locally to assist you in debugging. I want to make sure I understand the use case first:
Is there anyway you can give me a set of local commands I can use to replicate running this script? I tried to simplify the
Then run this to start netcat in UDP mode And then run this to send a message Sadly nothing ended up happening at this point. |
Could a member transfer this to nodejs/help? |
I guess github didn't notify me vía email. Just saw all the activity. @skye-lopez Thanks your your time, you understood correctly, I'll write something to replicate asap, since on my test environment I'm sending test messages from a mikrotik router. |
nodejs/help is better for issues that behave as expected when executed normally compared to with other programs. If new evidence comes to light, it can always be moved back. |
@redyetidev I tried reaching the v8 repo and seems to have issues disabled, where I can ask someone to explain to me that stack trace? I think that's the key to solving this. @skye-lopez I was able to reproduce it using netcat, seems like syslog interprets the first word as the hostname and the second one as the programname.
being 127.0.0.1 the variable %hostname% and whatever,here %programname% With that, it invokes the node app and gives the same crash. If this last thing it's the root cause, It won't be wasted time since this issue may help someone else. |
V8 issues can be reported at https://issues.chromium.org/issues/wizard, but this isn't (hopefully) an issue with V8. |
I don't think it's an issue with V8, more like a permissions thing with this VM, but V8 shouldn't crash, instead catch the exception and give an error I think? |
I've got not so good news. Tried a 100% clean install of Rocky Linux 9, only did a dnf update, installed curl and nano, nvm and node and loaded the configs on rsyslogd. It's still crashing. :( I've opened an issue today morning on that link, no updates at all. Maybe there is anyone who we can tag that understands the stack trace?
|
I did not get any crash output with my config. Could you try to test with this slimmed down version of rsyslog? I will also try to replicate with yours @alan-netmesh My feeling is this is a system or config issue... But I could be wrong. Again just for context to reproduce: Im on Ubuntu 24.04 LTS (native, not a vm) Node v18.19.1 my
Started netcat: Ran your test string: My output:
My test.js file:
|
@skye-lopez I'll try your config. But isn't about syslog or the node app. I've got an rsyslog instance with 300 or so filters on a ruleset, im quite familiar with it. I bet it's a rsyslog and/or V8 problem ONLY on RL9, since the production it's Debian 11 for well over two years (uptime now it's on 400+ days and I've restarted that thing a couple of times) Your output (stdout from omprog) on the file "[...]/test/test.log" should be "Match RegEx: 333 Hello World 111" or whatever numbers you put to match the regex. |
looking at int ret = mprotect(address, size, prot);
// Setting permissions can fail if the limit of VMAs is exceeded.
// Any failure that's not OOM likely indicates a bug in the caller (e.g.
// using an invalid mapping) so attempt to catch that here to facilitate
// debugging of these failures.
if (ret != 0) CHECK_EQ(ENOMEM, errno); looks like v8 anticipates only so I would say v8 failed to foresee and handle a scenario where |
Hey! Hope you're having a good morning. Thanks very very much for your input, that's what I wanted from the start, someone that could help understanding what the stack trace meant. I have some thoughts about this and I think it might come from the sandbox that rsyslog makes when launching a process. Since I tried to replicate this exact same setup on Debian as @skye-lopez did, and it doesn't crash. Not really sure if it's worth to continue chasing the tail about this, but when launching the process as interactive mode with root permissions, it just works (to the day, I don't know the difference on how rsyslog launches on RHEL-based and Debian-based systems). I'm open to comments and suggestions, if any of the resources I have on hand can help to nodejs. |
thanks @alan-netmesh for the pointers. then with reasonable confidence I can assert that can you run once with |
Hey Gireesh, thanks to you for the commitment on the issue. I've succedeed to launch it as root (not via rsyslog as interative w/root perms, literally as root user), but I don't think this trace helps, since the program runs just fine this way. |
ya - but as expected, all 50+ instances of mprotect returned 0, which means those all succeeded.
we need the same for the failing context. looking at your script, I guess we need adjustments here for the redirection? for example, define
|
--stdin in my script only makes the script read the message from stdin instead of --msg which would be a argument, so it doesn't do anything, that's there because rsyslog pipes the message instead of being on a variable. I've tried this:
Without success, on /var/log/messages it says something along the lines of It can't be very hard, I'm pretty sure im almost there. One or two cups of coffee and I'll be back with the strace. |
why don't you ask the |
Got some news! Still cannot get any output from strace when launched from rsyslog, but I managed to find out that the culprit its MemoryDenyWriteExecute on the systemd file of rsyslog. By default it comes yes, and on debian it comes undefined, that's why it doesn't crashes on Ubuntu and/or Debian. |
that makes sense! the doc says: so the obvious solution is to set the value to if possible, lets still see if you can get strace output to see if mprotect throws |
Hey, some users in nodejs/node are reporting the same behavior, so maybe this issue should be transferred there? |
@alan-netmesh - is your issue resolved? |
Hey Gireesh. I wasn't able to retrieve any strace output to report back then forgot about this. At least for me, we can mark this as solved. Feel free to tag me on any issue related to rsyslog + node if someone needs help. |
Version
22.6.0
Platform
Subsystem
No response
What steps will reproduce the bug?
Not sure how to reproduce it, since I don't really understand the stack trace. My app it's intended to recieve a string from stdin, store that in a variable, strip some parts of it (with regex.test) and send a post request. If I run it from cli (i.e. cat myfile | node app.js) it works just fine.
How often does it reproduce? Is there a required condition?
It happens only and every single time that Rsyslog tries to run my (quite simple) Node app using omprog module.
What is the expected behavior? Why is that the expected behavior?
The expected behavior it's a console.log() inside my app.js that outputs the line received from stdin, or a message "Line didn't match regex", it's pretty much the only purpose of the app.
What do you see instead?
Additional information
It's a Rocky Linux 9 server, NodeJS installed using nvm (nvm installed with bash script, nothing out of the ordinary) and SELinux it's on permissive (at first I thought that it might be that)
Rsyslog version: rsyslogd: version 8.2310.0-4.el9
The os it's fully up to date, no extra repos apart from EPEL.
The exact same setup (Rsyslog + Omprog module + NodeJS APP) It's been running on a debian box for well over a year, the only changes are Node version and the underlying os, moving from Debian to RL9.
The text was updated successfully, but these errors were encountered: