Troubleshooting
Node-RED gone after hours: the librdkafka segfault
Short answer
A Node-RED process that vanishes after hours, with only audit lines left in its own log, was killed by the kernel. One line in /var/log/syslog names the cause: a segfault in librdkafka.so.1, the native client the rdkafka node loads. Confirm by elimination, update or rebuild the module, move the publish out of the process, and add automatic restart.

On this page
A Node-RED process that disappears after a few hours, leaving only [audit] lines in its own log while the rest of the device runs normally, was not stopped by Node-RED: the kernel killed it. On the reported install — an IOT2040 edge device running Node-RED v0.18.4 on Node.js v6.12.3, Linux 4.4.105-cip15 ia32, launched at boot from a shell script in /etc/init.d/ — the proof was one line in /var/log/syslog: a segfault in librdkafka.so.1, the native Kafka client that the node-red-contrib-rdkafka node loads to publish to a Kafka cluster. Upgrading Node-RED or Node.js on its own does not remove that fault. Read the kernel line, confirm the node by elimination, then update or rebuild the native module, move the Kafka publish out of the process if the image cannot build it, and add automatic restart so a crash costs seconds instead of hours.
What the symptom tells you #
A report that Node-RED stops working needs pinning down before any fix, because four different failures look alike from the outside and leave different evidence.
| Observation | What it points to | Where the proof is |
|---|---|---|
Process absent from the process list; Node-RED log ends on [audit] lines with trace level on |
Abrupt termination: a native crash or an external kill | The kernel log: /var/log/syslog or dmesg output |
| Process present, editor and flows unresponsive | Event-loop block, memory pressure or a deadlock | CPU and memory trend of the process; no kernel line |
| Process absent; kernel log records an out-of-memory kill | The kernel's OOM killer | dmesg output and the memory trend before the stop |
| Process absent; kernel log records a segfault in a loaded library | A native-code fault in that library | The library name in the same kernel line |
| Process gone only after boot-script edits or a logout | Start method tied to a terminal or session | The launch line in the init script |
The reported install sits in the fourth row. Relaunching Node-RED brought everything back, so the operating system and the hardware were healthy, and the trace-level setting in the Node-RED logging configuration produced nothing useful — the logger runs inside the process that died, and whatever it had buffered was lost with it. The start method mattered too: a shell script in /etc/init.d/ runs once at boot and nothing brings the process back afterwards, which is why every crash lasted until a person relaunched it.
Why the Node-RED log stays silent #
Node-RED logs from JavaScript, and a catch block or an error handler only sees faults raised in JavaScript. A node that wraps a C library — the rdkafka node wraps the librdkafka client — runs that library's code on its own threads inside the same process; librdkafka names its internal threads with the rdk: prefix, the broker connection thread being rdk:broker-1 here. When one of those threads touches an address the process has not mapped, the memory-protection hardware raises a segmentation fault and the kernel terminates the whole process at once. No catch block runs, no handler runs, no buffered log line is flushed. The only record of the event is the one line the kernel itself puts in the system log.
The line in the syslog that names the cause #
The kernel logged this on the device:
user.info kernel: rdk:broker-1[437]: segfault at b2aeab9b ip b28f0b80 sp b0 2ff01c error ffff0004 in librdkafka.so.1[b28e9000+10b000]
Read it field by field:
- Task name
rdk:broker-1— the faulting thread is a librdkafka broker thread, not the Node.js main thread. The bracketed number is the thread's process ID at the moment of the crash. - Library mapping — the bracket after the file name gives the base address and the mapped size, both hexadecimal, so the mapping ends at
0xb28e9000 + 0x10b000 = 0xb29f4000. - Instruction pointer — it falls inside the mapping. The offset into the library is the instruction pointer minus the base printed in the same line:
0xb28f0b80 - 0xb28e9000 = 0x7b80. Runaddr2line -eagainst an unstripped copy of that exact build with this offset, and it resolves to a function and a source line. Addresses move between runs because of address-space layout randomization, so always subtract the base printed in the same line, never one from an earlier line. - Fault address —
0xb2aeab9bsits0xf6b9bbytes, about 1 MB, above the mapping end, so the thread read memory outside the library image: an unmapped address. On a 32-bit install that is the signature of a stale pointer — memory already freed — or of a layout mismatch between the wrapper and the library build. - Error bits — the low bits of the error field carry the x86 page-fault flags. 0x4 is binary 0100: bit 2 set means the access came from user mode, and bits 1 and 0 clear mean a read of a page that is not mapped. The upper half belongs to how this kernel prints the field and adds no defined x86 flag.
- Stack pointer field — the transcribed line shows it split by a stray space. Copy the line off the device as a file instead of retyping it, and keep that in mind when the report goes upstream.
What the line cannot say is which event walked the thread into that address — a broker reconnect, a metadata refresh or a teardown of the produce queue all end in the same broker thread. Compare the crash timestamps with the Kafka cluster's broker logs for connection resets or leader changes in the same minutes.
Confirm the node by elimination #
- Confirm the process is gone rather than hung:
ps aux | grep node-redreturns only the grep line. - Search the kernel log with
grep -i segfault /var/log/sysloganddmesg | grep -i segfault. Record the timestamp, task name and library for every hit. - Match each timestamp against the last
[audit]line in the Node-RED log and against the Kafka broker logs around the same minute. - Read the versions for the report:
npm lsin the Node-RED user directory for the rdkafka package, plus the Node.js and Node-RED versions from the startup banner and the platform line, ia32 here. - Disable or remove the flow that uses the Kafka node, leave every other flow running, and soak the device longer than the previous time to failure. If the process stays up past that point, the Kafka node is the cause.
- Optional, for a backtrace: raise the core limit in the launch script before Node-RED starts (
ulimit -c unlimited), make sure the core path is writable, and check free flash first — a core of a 32-bit Node process runs large.
Fixes, in the order to try them #
- Update the node, rebuild the module. Update
node-red-contrib-rdkafkato its current release, which pulls a current librdkafka build, and rebuild the native module against the Node.js ABI on the device — on the reported image, a build for ia32 against Node.js 6, on the device or cross-built. The procedure in rebuilding Node-RED serialport modules on a 32-bit ARM edge PC carries over step for step, ABI check included. - Check the firmware ceiling before planning a bigger jump. Node-RED 0.20.x needs Node.js 8, and the newest image reported for the IOT2040 at the time still shipped Node.js 6.14.3, so a current runtime meant building a new image rather than updating packages. Where your edge-device vendor publishes the Node.js versions its image supports, that list decides whether a rebuilt module has a runtime to run on — check it first.
- Move the Kafka publish out of the Node-RED process. A small separate producer takes the same data from Node-RED over a local MQTT broker or an HTTP POST; a crash then kills only the producer while Node-RED, the dashboard and every other flow keep running. The trade-off between a broker hop and a raw socket is laid out in MQTT broker versus direct TCP from a Node-RED edge device. If the edge box has no spare capacity for a second process, a separate fanless mini PC dedicated to the Kafka publish keeps the next native crash off the Node-RED host entirely.
- Add automatic restart whatever else you choose. A unit with
Restart=on-failurewhere systemd exists turns the same crash into a seconds-long gap, as walked through in Node-RED crash and memory growth: systemd restart recovery; in a container, the restart policy does the same job, as in auto-restart Node-RED in Docker after exit code 255. Where neither exists, a short watchdog loop in the init script — check the PID, relaunch on death — is enough. Restarting does not fix the defect and loses whatever the flows held in memory, so pair it with fix 1 or fix 3.
One caution belongs with the supervision fix: if any flow on this host writes values that a machine or an operator acts on, treat a silent process death as a stale-data hazard — have consumers treat a missed heartbeat as a fault and move to a defined state instead of holding the last value. Supervision shortens the gap; it does not close it.
Report it upstream #
Take the fault to the maintainers of the node and of the client library; intermittent crashes during broker teardown are reported against librdkafka itself, which is why the library update in fix 1 matters as much as the wrapper update. A report that can be acted on carries:
- the original kernel line, copied off the device as a file rather than retyped;
- the offset computed from that same line;
- the package versions from
npm ls, plus the Node.js, Node-RED and kernel versions and the platform, ia32 here; - the exact file behind the
librdkafka.so.1name, with an unstripped copy of the same build if one exists, because the offset resolves to a function only against that build.
The decision for each case #
- Segfault in a library a native node loaded, Node-RED log silent on the death: a native-module fault. Update or rebuild that module and its client library against the device's ABI; where the image cannot build it, move that publish to a separate producer process. Add automatic restart in every case.
- Out-of-memory kill in the kernel log: not this fault. Find and cap the memory growth first; a supervisor without the fix only schedules the next stop.
- Process alive but unresponsive with a clean kernel log: an event-loop block or a deadlock; profile the process before touching versions.
- Closing the case: after the module update or the move, soak the device longer than the previous time to failure — a run that outlasts the old hours-to-crash interval with the Kafka node updated or external closes the fault.
Questions asked
How do I find the actual library file behind the name in the kernel line?
The name in the kernel line is a symlink, not the file itself. From the Node-RED user directory, the file sits inside the rdkafka package's build output under node_modules. Record its size and build date, and keep that exact file, plus an unstripped copy of the same build if one exists, when the report goes upstream: the offset from the kernel line only resolves against the build that produced it.
My syslog line shows different addresses than the example. Same fault?
Most likely yes. Address-space layout randomization gives the library a new base at every launch, so the raw addresses change while the fault stays the same. Subtract the base printed in your line from the instruction pointer in the same line and compare that offset between runs. A repeating offset points at the same instruction; a different offset in the same library means a second fault worth its own investigation.
Can a core dump tell me more than the syslog line?
Yes. Raise the core size limit in the launch script before Node-RED starts, point the core path at somewhere writable and check free flash first, because a core of a 32-bit Node process runs large. Opened in a debugger against the matching unstripped library, the core gives a full backtrace of the broker thread where the syslog line gives one address.
What if the syslog shows an out-of-memory kill instead of a segfault?
That is a different failure and needs a different answer. The kernel's out-of-memory killer picks the process with the worst memory score, kills it and logs the decision; nothing in Node-RED failed at that instant. Look at the memory trend before the stop and at flows that accumulate data, fix or cap the growth, and only then add automatic restart — restarting a process that grows without limit just schedules the next outage.
Relaunching Node-RED by hand brings everything back. Is that enough?
It restores service, but it leaves the native defect in place and it depends on somebody noticing the dead process. Every crash also drops what the flows held in memory, including any messages queued for Kafka. Automatic restart makes the recovery fast, and the module update or the separate producer removes the crash itself; the fix is the pair together, not either one alone.


