Closed Zaaler closed 2 years ago
I was trying to use multiple nodes in a single thread. I don't think rclnodejs is capable of this.
Sorry for the delay, yes, we haven't tested with multi-thread scenario, e.g., on different worker threads. Because some rcl functions wrapped by rclnodejs (or nodejs bindings) are not thread-safe, we'd better run in a single thread or you can run on different processes. @Zaaler
I have a dispatcher that creates two workers. One worker creates an rclnodsj node and subscribes to a point cloud topic. The other worker also creates a rclnodejs node and subscribes to the same topic. Both workers tell the nodes to spin. The first work starts up correctly and processes a message but, when the second work starts up, the code crashes and I get this error: ` const rtn = exports._reinterpret(buffer, size, offset || 0); ^
Error: reinterpret: Cannot reinterpret from nullptr pointer`
If I run just one of the workers, the code works correctly. Also, if I set isRaw to true, both workers can run without causing eachother to crash.
This might be a problem because I am using a single thread to run multiple nodes. Has anyone tried anything like this? I went down the path of looking into workers and implementing threading but, after I ran both nodes with the isRaw = true and saw they could process the data that way, I backed up.
Steps To Reproduce
Expected Behavior Both nodes are able to receive messages from the topic without crashing.
Actual Behavior The first node that connects crashes when the second node tries to process its callback.