Skip to content
This repository was archived by the owner on May 31, 2025. It is now read-only.
This repository was archived by the owner on May 31, 2025. It is now read-only.

Race condition between roscore and roslaunch --wait #1097

@drigz

Description

@drigz

Steps to reproduce

echo "<launch></launch>" > launch.xml
roscore & roslaunch --wait launch.xml

Rarely, both roscore and roslaunch will start the rosout node. If this happens, the rosout nodes will conflict forever as they are both started with respawn="true".

To make this more likely to happen, you can do the following:

edit _setup() in roslaunch/launch.py:
        self._launch_master()
        import random
        time.sleep(random.random())
        self._launch_core_nodes() 
edit _wait_for_master() in roslaunch/rlutil.py:
    while not is_running:
        # time.sleep(0.1)
        is_running = m.is_running()
run this script and look for multiple "started core service" lines:
    #!/bin/bash
    export PYTHONUNBUFFERED=yes
    roscore | sed -n "/core service/ {s/^/roscore: /; p}" &
    for i in $(seq 1 100); do
      roslaunch --wait launch.xml | sed -n "/core service/ {s/^/roslaunch $i: /; p}" &
    done
    sleep 5
    pkill -P $$
    wait

Explanation

If you run roslaunch --wait, it will wait for the master before starting, but the --wait flag has no effect on the starting of core nodes. In roslaunch/launch.py, we have:

        # start up the core: master + core nodes defined in core.xml
        self._launch_master()
        self._launch_core_nodes() 

unconditionally of whether --core or --wait is used. In the --wait case, rlutil._wait_for_master has already been called, and _launch_master() notices that the master is already running so does nothing. However, _launch_core_nodes may still try to launch rosout if the roscore hasn't started it yet.

Workaround

Run this command before roslaunch --wait:

until rosnode info rosout | grep Pid; do sleep 1; done

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions