Skip to content

Simulator: h_launch_app accepts unknown app names silently #9

Description

@jeffory

Problem

h_launch_app in simulator/sim_socket_handler.c (~line 396) queues the requested app name and unconditionally returns {"ok": true}. The actual lookup happens later, on the OS poll loop, via launcher_launch_by_name(). If the name doesn't match anything in s_apps[], that lookup silently no-ops — but the RPC caller has already been told the launch succeeded.

static char *h_launch_app(const char *params) {
    char name[128] = {0};
    json_get_str(params, "name", name, sizeof(name));
    if (!name[0]) {
        return strdup("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32602,\"message\":\"name required\"}}");
    }
    s_pending_launch = strdup(name);
    static char buf[256];
    snprintf(buf, sizeof(buf),
             "{\"jsonrpc\":\"2.0\",\"result\":{\"ok\":true,\"app_name\":\"%s\"}}", name);
    return strdup(buf);
}

Compounding this: scan_apps() (src/os/launcher.c) runs once at boot. Any app staged onto the SD card after the simulator process has already started is invisible to the launcher for the lifetime of that process — while launch_app still reports success.

Impact

This cost real debugging time during e2e test development: a launch RPC would report ok: true and the test would then wait/poll for behavior that could never happen, with no error signal pointing at the actual cause (stale app list / typo'd app name).

Suggested direction

  • Validate the requested name against s_apps[] in h_launch_app (or at the point s_pending_launch is consumed) and return an RPC error if it isn't found.
  • Consider adding an RPC to trigger scan_apps() again, so tests don't need to restart the simulator after staging a new app onto the SD image.

Context

Surfaced while implementing Stage 0/1 of the C-Dogs asset-memory redesign (local specs, not tracked in this repo). Parent commits e9b1622e..21a9b389.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions