Skip to content

[Bug]: Pub/Sub crashes across schedulers when using Image messages (separate processes) #37

@gelanchez

Description

@gelanchez

Bug Description

When using HORUS pub/sub across two different files, each running its own scheduler, the subscriber node crashes when publishing/subscribing Image messages.

The exact same nodes work correctly when both publisher and subscriber are run in the same binary with a single scheduler.

Steps to Reproduce

  1. Create a publisher node that publishes an Image message on a topic.
  2. Create a subscriber node that subscribes to the same topic.
  3. Compile and run each node as a separate binary, each with its own Scheduler.
  4. Observe that the subscriber crashes at runtime.
  5. Run both nodes in the same binary and scheduler → the image is received correctly.

Expected Behavior

Image pub/sub works across schedulers/processes. If an error happens, a runtime error should be raised.

Actual Behavior

Process [node] exited with code: -1

HORUS Version

0.1.7

Operating System

Ubuntu 24.04

Rust Version

rustc 1.92.0

Language

Rust

Minimal Code Example

test.rs

use horus::prelude::*;

node! {
    TestSendNode {
        name: "test_send_node",
        rate 1.0
        pub {
            test_pub: Image -> "test_send.image"
        }
        tick(ctx) {
            let width = 324;
            let height = 244;
            let pixels = vec![0u8; width * height * 3]; // Empty image
            let image = Image::new(width as u32, height as u32, ImageEncoding::Rgb8, pixels);

            let _ = self.test_pub.send(image, &mut ctx);
        }
    }
}

fn main() -> Result<()> {
    let mut scheduler = Scheduler::new().name("test_scheduler");

    scheduler.add(Box::new(TestSendNode::new()), 1, Some(true));

    // Run the scheduler loop - continuously ticks all nodes
    let _ = scheduler.run();
    Ok(())
}

test_receive.rs

use horus::prelude::*;

node! {
    TestReceiveNode {
        name: "test_receive_node",
        rate 5.0
        sub {
            test_sub: Image -> "test_send.image"
        }
        tick(ctx) {
            if let Some(image) = self.test_sub.recv(&mut ctx) {
                if image.is_valid() {
                    println!("Received image");
                }
            }
        }
    }
}

fn main() -> Result<()> {
    let mut scheduler = Scheduler::new().name("test_receive_scheduler");

    scheduler.add(Box::new(TestReceiveNode::new()), 1, Some(true));

    // Run the scheduler loop - continuously ticks all nodes
    let _ = scheduler.run();
    Ok(())
}

Relevant Logs

Process [test_receive] exited with code: -1

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions