{"record":{"id":"d7b3a368377715a0","repo":"ReFirmLabs/binwalk","slug":"no-available-worker-threads","errorCode":null,"errorMessage":"No available worker threads!","messagePattern":"No available worker threads!","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/main.rs","lineNumber":127,"sourceCode":"        Ok(bw) => bw,\n    };\n\n    // If the user specified --threads, honor that request; else, auto-detect available parallelism\n    let available_workers = cliargs.threads.unwrap_or_else(|| {\n        // Get CPU core info\n        match thread::available_parallelism() {\n            // In case of error use the default\n            Err(e) => {\n                error!(\"Failed to retrieve CPU core info: {e}\");\n                DEFAULT_WORKER_COUNT\n            }\n            Ok(coreinfo) => coreinfo.get(),\n        }\n    });\n\n    // Sanity check the number of available worker threads\n    if available_workers < 1 {\n        panic!(\"No available worker threads!\");\n    }\n\n    // Initialize thread pool\n    debug!(\"Initializing thread pool with {available_workers} workers\");\n    let workers = ThreadPool::new(available_workers);\n    let (worker_tx, worker_rx) = mpsc::channel();\n\n    /*\n     * Set a custom panic handler.\n     * This ensures that when any thread panics, the default panic handler will be invoked\n     * _and_ the entire process will exit with an error code.\n     */\n    let default_panic_handler = panic::take_hook();\n    panic::set_hook(Box::new(move |panic_info| {\n        default_panic_handler(panic_info);\n        process::exit(-1);\n    }));\n","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/ReFirmLabs/binwalk/blob/26713972e3f9f52dc37d4a421c4554b0bd9e82ef/src/main.rs#L109-L145","documentation":"A startup sanity check panic: the code queried the number of available worker threads (e.g. via std::thread::available_parallelism) and got a value below 1. Since a thread pool with zero workers can never process files, main() panics immediately rather than proceeding.","triggerScenarios":"available_parallelism() returning Ok(0) or a default path yielding 0 — e.g. running under a cgroup/container with an empty or restricted CPU affinity mask, or a sandboxing layer reporting no usable CPUs.","commonSituations":"Containers/Docker with cpuset quotas pinned to zero CPUs; CI runners with restricted sched_getaffinity; unusual sandboxes (gVisor, some HPC schedulers) that report 0 processors.","solutions":["Inspect the runtime environment: run `nproc` / check cgroup cpu.max and cpuset to confirm at least one CPU is visible","Adjust container/sandbox CPU limits so at least 1 CPU is available","Fall back to a minimum of 1 worker thread instead of panicking","Optionally allow a --workers CLI flag to override auto-detection"],"exampleFix":"// before\nif available_workers < 1 {\n    panic!(\"No available worker threads!\");\n}\n// after\nlet available_workers = available_workers.max(1);\ndebug!(\"Using {available_workers} workers\");","handlingStrategy":"validation","validationCode":"let workers = std::thread::available_parallelism()\n    .map(|n| n.get())\n    .unwrap_or(1)\n    .max(1);","typeGuard":"fn sane_worker_count(n: usize) -> usize { if n < 1 { 1 } else { n } }","tryCatchPattern":null,"preventionTips":["Always clamp detected worker counts to a minimum of 1","Check container CPU limits (cgroups) before deploying","Add a startup log of detected CPU count for diagnostics","Offer a CLI flag to override auto-detected worker count"],"tags":["rust","panic","threading","configuration"],"backgroundTag":"invalid-config-value","analyzedSha":"26713972e3f9f52dc37d4a421c4554b0bd9e82ef","analyzedAt":"2026-09-06T21:38:04.941Z","contentChangedAt":"2026-09-06T21:38:04.941Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}