{"id":13472506,"url":"https://github.com/awslabs/shuttle","last_synced_at":"2025-12-12T15:36:55.283Z","repository":{"id":39790648,"uuid":"343548793","full_name":"awslabs/shuttle","owner":"awslabs","description":"Shuttle is a library for testing concurrent Rust code","archived":false,"fork":false,"pushed_at":"2024-05-17T21:28:01.000Z","size":440,"stargazers_count":578,"open_issues_count":17,"forks_count":29,"subscribers_count":18,"default_branch":"main","last_synced_at":"2024-05-22T20:32:47.797Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/awslabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-01T20:32:26.000Z","updated_at":"2024-05-31T20:31:51.536Z","dependencies_parsed_at":"2023-12-11T14:27:32.519Z","dependency_job_id":"e0e8eb1b-ff44-409a-82e0-a9be44fc2b76","html_url":"https://github.com/awslabs/shuttle","commit_stats":{"total_commits":136,"total_committers":13,"mean_commits":"10.461538461538462","dds":0.4117647058823529,"last_synced_commit":"fad695c8e1f4dc217d81b78079ab4b9775ae85c9"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awslabs%2Fshuttle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awslabs%2Fshuttle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awslabs%2Fshuttle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awslabs%2Fshuttle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/awslabs","download_url":"https://codeload.github.com/awslabs/shuttle/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222156475,"owners_count":16940436,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T16:00:55.212Z","updated_at":"2025-12-12T15:36:50.263Z","avatar_url":"https://github.com/awslabs.png","language":"Rust","funding_links":[],"categories":["Projects","Rust","Dynamic Checkers"],"sub_categories":["Verification"],"readme":"# Shuttle\n\n[![crates.io](https://img.shields.io/crates/v/shuttle.svg)](https://crates.io/crates/shuttle)\n[![docs.rs](https://docs.rs/shuttle/badge.svg)](https://docs.rs/shuttle)\n[![Tests](https://github.com/awslabs/shuttle/actions/workflows/tests.yml/badge.svg)](https://github.com/awslabs/shuttle/actions/workflows/tests.yml)\n\nShuttle is a library for testing concurrent Rust code. It is an implementation of a number of\n*randomized concurrency testing* techniques, including\n[A Randomized Scheduler with Probabilistic Guarantees of Finding Bugs](https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/asplos277-pct.pdf).\n\n## Getting started\n\nConsider this simple piece of concurrent code:\n\n```rust\nuse std::sync::{Arc, Mutex};\nuse std::thread;\n\nlet lock = Arc::new(Mutex::new(0u64));\nlet lock2 = lock.clone();\n\nthread::spawn(move || {\n    *lock.lock().unwrap() = 1;\n});\n\nassert_eq!(0, *lock2.lock().unwrap());\n```\n\nThere is an obvious race condition here: if the spawned thread runs before the assertion, the\nassertion will fail. But writing a unit test that finds this execution is tricky. We could run\nthe test many times and try to \"get lucky\" by finding a failing execution, but that's not a very\nreliable testing approach. Even if the test does fail, it will be difficult to debug: we won't\nbe able to easily catch the failure in a debugger, and every time we make a change, we will need\nto run the test many times to decide whether we fixed the issue.\n\n### Randomly testing concurrent code with Shuttle\n\nShuttle avoids this issue by controlling the scheduling of each thread in the program, and\nscheduling those threads *randomly*. By controlling the scheduling, Shuttle allows us to\nreproduce failing tests deterministically. By using random scheduling, with appropriate\nheuristics, Shuttle can still catch most (non-adversarial) concurrency bugs even though it is\nnot an exhaustive checker.\n\nA Shuttle version of the above test just wraps the test body in a call to Shuttle's\n`check_random` function, and replaces the concurrency-related imports from `std` with imports\nfrom `shuttle`:\n\n```rust\nuse shuttle::sync::{Arc, Mutex};\nuse shuttle::thread;\n\nshuttle::check_random(|| {\n    let lock = Arc::new(Mutex::new(0u64));\n    let lock2 = lock.clone();\n\n    thread::spawn(move || {\n        *lock.lock().unwrap() = 1;\n    });\n\n    assert_eq!(0, *lock2.lock().unwrap());\n}, 100);\n```\n\nThis test detects the assertion failure with extremely high probability (over 99.9999%).\n\nShuttle is inspired by the [Loom](https://github.com/tokio-rs/loom) library for\ntesting concurrent Rust code.  Shuttle focuses on randomized testing, rather\nthan the exhaustive testing that Loom offers. This is a soundness—scalability\ntrade-off: Shuttle is not sound (a passing Shuttle test does not prove the code\nis correct), but it scales to much larger test cases than Loom. Empirically,\nrandomized testing is successful at finding most concurrency bugs, which tend\nnot to be adversarial.\n## License\n\nThis project is licensed under the Apache-2.0 License.\n\n## Security\n\nSee [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawslabs%2Fshuttle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fawslabs%2Fshuttle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawslabs%2Fshuttle/lists"}